Files
wordpress-theme-aksrt/assets/creator-studio/build/index.js
T
kate522 4cd296c066 refactor(creator-studio): pick the cover from the toolbar image dialog
The cover row carried its own hidden file input and upload call, so authors
had two different image flows in one page.

- 添加封面 now opens window.JioSubmitMedia with type=image, the same dialog
  the toolbar's 图片 button uses (mine / upload / external link).
- The picked image is stored as the full-size URL plus its attachment id,
  matching FrontSubmitFeatured's image branch, which re-checks ownership
  and sets the post thumbnail.
- Removes the now-unused uploadCover path, apiUpload/nonce imports, and the
  .jio-creator__cover-input rule.

Contract added; 887 widget-system tests pass.
2026-11-09 15:57:30 +08:00

10 lines
74 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(()=>{"use strict";const e=window.React,t=window.wp.element,a=window.wp.i18n;function n(e,t){const a=e&&(e.message||e.error)||(401===t?"登录状态已失效,请刷新页面重新登录。":"请求失败,请稍后重试。"),n=new Error(String(a));return n.status=t,n.code=e&&e.code?String(e.code):"",n.data=e,n}async function o(e){try{return await e.json()}catch(e){return null}}async function r(e,t,a){const r=await fetch(e,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":a},body:JSON.stringify(t)}),i=await o(r);if(!r.ok)throw n(i,r.status);return i}const i={url:"",attachmentId:0,extractCode:"",copyKey:"",copyVal:"",label:"",class:""};function l({row:n,buttonClasses:o,onPickAttachment:r,onSubmit:l,onClose:c}){const[s,d]=(0,t.useState)(()=>n?{url:String(n.url||""),attachmentId:Number(n.attachmentId||0),extractCode:String(n.extractCode||""),copyKey:String(n.copyKey||""),copyVal:String(n.copyVal||""),label:String(n.label||""),class:String(n.class||"")}:{...i}),[m,u]=(0,t.useState)(""),p=(0,t.useRef)(null);(0,t.useEffect)(()=>{p.current?.focus();const e=e=>{"Escape"===e.key&&(e.preventDefault(),c())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c]);const _=e=>d(t=>({...t,...e}));return(0,e.createElement)("div",{className:"jio-creator-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-resource-title"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__backdrop","aria-label":(0,a.__)("关闭","jio"),onClick:c}),(0,e.createElement)("div",{className:"jio-creator-dialog__panel jio-creator-dialog__panel--wide"},(0,e.createElement)("header",{className:"jio-creator-dialog__head"},(0,e.createElement)("h2",{id:"jio-creator-resource-title"},n?(0,a.__)("编辑资源","jio"):(0,a.__)("添加资源","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__close",onClick:c,"aria-label":(0,a.__)("关闭","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,e.createElement)("div",{className:"jio-creator-dialog__body"},(0,e.createElement)("label",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("下载地址","jio")),(0,e.createElement)("div",{className:"jio-creator-dialog__url"},(0,e.createElement)("input",{ref:p,type:"url",value:s.url,placeholder:(0,a.__)("请输入资源下载地址","jio"),onChange:e=>_({url:e.target.value,attachmentId:0}),onPaste:e=>{const t=e.clipboardData?.getData("text")||"";if(!t)return;const n=t.match(/https?:\/\/\S+/i),o=t.match(/(?:提取码|密码)\s*[::]\s*([A-Za-z0-9]{4,8})/);if(!n&&!o)return;e.preventDefault();const r={attachmentId:0};n&&(r.url=n[0].replace(/[)\],。]+$/u,"")),o&&(r.extractCode=(0,a.sprintf)(/* translators: %s: extraction code */ /* translators: %s: extraction code */
(0,a.__)("提取码:%s","jio"),o[1]),r.copyKey=(0,a.__)("提取码","jio"),r.copyVal=o[1]),_(r)}}),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__ghost",onClick:()=>r((e,t)=>_({url:e,attachmentId:t}))},(0,e.createElement)("i",{className:"fa fas fa-upload","aria-hidden":"true"})," ",(0,a.__)("上传附件","jio"))),(0,e.createElement)("span",{className:"jio-creator-dialog__hint"},(0,a.__)("支持直接粘贴网盘分享链接,会自动识别提取码。","jio"))),(0,e.createElement)("label",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("资源备注","jio")),(0,e.createElement)("input",{type:"text",value:s.extractCode,placeholder:(0,a.__)("例如提取码、解压密码等","jio"),onChange:e=>_({extractCode:e.target.value})})),(0,e.createElement)("div",{className:"jio-creator-dialog__row"},(0,e.createElement)("label",null,(0,e.createElement)("span",null,(0,a.__)("复制名称","jio")),(0,e.createElement)("input",{type:"text",value:s.copyKey,placeholder:(0,a.__)("如:提取码","jio"),onChange:e=>_({copyKey:e.target.value})})),(0,e.createElement)("label",null,(0,e.createElement)("span",null,(0,a.__)("复制内容","jio")),(0,e.createElement)("input",{type:"text",value:s.copyVal,placeholder:(0,a.__)("如:abcd","jio"),onChange:e=>_({copyVal:e.target.value})}))),(0,e.createElement)("span",{className:"jio-creator-dialog__hint"},(0,a.__)("填写后读者可点击按钮复制这段内容。","jio")),(0,e.createElement)("label",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("自定义按钮文案","jio")),(0,e.createElement)("input",{type:"text",value:s.label,placeholder:(0,a.__)("留空则按网盘自动识别","jio"),onChange:e=>_({label:e.target.value})})),(0,e.createElement)("div",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("按钮样式","jio")),(0,e.createElement)("div",{className:"jio-creator-swatches"},o.map(t=>(0,e.createElement)("button",{key:t||"default",type:"button",className:`jio-creator-swatch ${t||"b-theme"}${s.class===t?" is-active":""}`,onClick:()=>_({class:t}),title:t||(0,a.__)("默认样式","jio"),"aria-label":t||(0,a.__)("默认样式","jio"),"aria-pressed":s.class===t})))),m&&(0,e.createElement)("p",{className:"jio-creator-error"},m)),(0,e.createElement)("footer",{className:"jio-creator-dialog__foot"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__ghost",onClick:c},(0,a.__)("取消","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__primary",onClick:()=>{const e=function(e){const t=e.trim();if(!t)return"";try{const e=new URL(t,window.location.href);return"http:"===e.protocol||"https:"===e.protocol?e.href:""}catch(e){return""}}(s.url);if(!e)return void u((0,a.__)("请填写有效的下载地址","jio"));u("");const t=/pan\.baidu\.com|aliyundrive\.com|alipan\.com|pan\.quark\.cn|cloud\.189\.cn|115\.com|lanzou|weiyun|123pan/i.test(e);l({...n||{},type:t?"net_disk":"direct",url:e,attachmentId:Math.max(0,Number(s.attachmentId)||0),extractCode:s.extractCode.trim(),copyKey:s.copyKey.trim(),copyVal:s.copyVal.trim(),label:s.label.trim(),class:s.class})}},(0,a.__)("确认","jio")))))}const c=(e,t=0)=>{const a=Number(e);return Number.isFinite(a)?a:t};function s({pay:n,onChange:o,canDownload:r,privateStorage:i,privateUploads:s,bootstrap:d,onUploadPrivate:m,uploading:u,uploadError:p,onPickAttachment:_}){const[f,b]=(0,t.useState)(null),g=(0,t.useRef)(null),h=e=>o({...n,...e}),j="points"===n.modo,y=String(d.currencySymbol||"¥"),v=d.downloadClasses&&d.downloadClasses.length>0?d.downloadClasses:["","c-blue","b-blue","jb-blue"],E=n.downloads,k=e=>j?(0,a.sprintf)(/* translators: %s: VIP level name */ /* translators: %s: VIP level name */(0,a.__)("%s 积分","jio"),e):(0,a.sprintf)(/* translators: %s: VIP level name */ /* translators: %s: VIP level name */(0,a.__)("%s 价格","jio"),e),N=(t,a,n,o)=>{var r;return(0,e.createElement)("label",{className:"jio-creator-input"},(0,e.createElement)("span",null,t),(0,e.createElement)("span",{className:"jio-creator-price"},o.prefix&&(0,e.createElement)("em",null,o.prefix),(0,e.createElement)("input",{type:"number",min:null!==(r=o.min)&&void 0!==r?r:0,step:o.step,value:a,placeholder:o.placeholder,onChange:e=>n(e.target.value)}),o.suffix&&(0,e.createElement)("em",null,o.suffix)))};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"jio-creator-switch"},(0,e.createElement)("div",null,(0,e.createElement)("h3",null,(0,a.__)("付费内容","jio")),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("开启后,未购买读者只能看到免费部分;添加下载资源后同时出售下载权限。","jio"))),(0,e.createElement)("label",{className:"jio-creator-toggle"},(0,e.createElement)("input",{type:"checkbox",checked:n.enabled,onChange:e=>h({enabled:e.target.checked})}),(0,e.createElement)("span",{"aria-hidden":"true"}))),n.enabled&&(0,e.createElement)("div",{className:"jio-creator-pay"},d.pointsEnabled&&(0,e.createElement)("div",{className:"jio-creator-segment",role:"group","aria-label":(0,a.__)("支付类型","jio")},(0,e.createElement)("button",{type:"button",className:"cash"===n.modo?"is-active":"","aria-pressed":"cash"===n.modo,onClick:()=>h({modo:"cash"})},(0,a.__)("现金支付","jio")),(0,e.createElement)("button",{type:"button",className:"points"===n.modo?"is-active":"","aria-pressed":"points"===n.modo,onClick:()=>h({modo:"points"})},(0,a.__)("积分支付","jio"))),j?N((0,a.__)("设置积分","jio"),String(n.points),e=>h({points:c(e)}),{min:Number(d.pointsMin||0),step:"1",suffix:(0,a.__)("积分","jio"),placeholder:"0"}):N((0,a.__)("设置价格","jio"),n.price,e=>h({price:e}),{min:Number(d.priceMin||0),step:"0.01",prefix:y,placeholder:"0.00"}),d.vipManual&&(d.vip1Enabled||d.vip2Enabled)&&(0,e.createElement)("div",{className:"jio-creator-vip-prices"},d.vip1Enabled&&(j?N(k(String(d.vip1Name||"VIP1")),String(n.vip1Points),e=>h({vip1Points:c(e)}),{step:"1",suffix:(0,a.__)("积分","jio"),placeholder:"0"}):N(k(String(d.vip1Name||"VIP1")),n.vip1Price,e=>h({vip1Price:e}),{step:"0.01",prefix:y,placeholder:"0.00"})),d.vip2Enabled&&(j?N(k(String(d.vip2Name||"VIP2")),String(n.vip2Points),e=>h({vip2Points:c(e)}),{step:"1",suffix:(0,a.__)("积分","jio"),placeholder:"0"}):N(k(String(d.vip2Name||"VIP2")),n.vip2Price,e=>h({vip2Price:e}),{step:"0.01",prefix:y,placeholder:"0.00"})),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("会员价不能高于普通价,填 0 表示会员免费。","jio"))),r&&(0,e.createElement)("div",{className:"jio-creator-attachments"},(0,e.createElement)("div",{className:"jio-creator-attachments__head"},(0,e.createElement)("div",null,(0,e.createElement)("h4",null,(0,a.__)("付费下载","jio")),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("添加网盘链接或受保护附件,读者付费后才能下载。","jio"))),(0,e.createElement)("div",{className:"jio-creator-attachments__actions"},(0,e.createElement)("button",{type:"button",className:"jio-creator-ghost",onClick:()=>b({row:null,index:-1})},(0,e.createElement)("i",{className:"fa fas fa-plus","aria-hidden":"true"})," ",(0,a.__)("添加资源","jio")),i&&(0,e.createElement)("label",{className:"jio-creator-upload"},(0,e.createElement)("input",{ref:g,type:"file",onChange:e=>{(async e=>{if(!e)return;const t=await m(e);t&&h({enabled:!0,downloads:[...E,t]}),g.current&&(g.current.value="")})(e.target.files?.[0])},disabled:u}),(0,e.createElement)("span",null,u?(0,a.__)("上传中…","jio"):(0,a.__)("上传私有附件","jio"))))),!i&&(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("私有附件存储尚未配置,只能添加外部下载地址。","jio")),p&&(0,e.createElement)("p",{className:"jio-creator-error"},p),E.length>0&&(0,e.createElement)("ul",{className:"jio-creator-files"},E.map((t,n)=>(0,e.createElement)("li",{key:`${t.assetKey||t.url}-${n}`},(0,e.createElement)("button",{type:"button",className:"jio-creator-files__name",onClick:()=>b({row:t,index:n}),title:(0,a.__)("编辑资源","jio")},(0,e.createElement)("i",{className:t.assetKey?"fa fas fa-lock":"net_disk"===t.type?"fa fas fa-cloud":"fa fas fa-link","aria-hidden":"true"}),t.label||t.extractCode||t.fileName||t.url),t.sizeLabel&&(0,e.createElement)("span",{className:"jio-creator-muted"},t.sizeLabel),(0,e.createElement)("button",{type:"button",className:"jio-creator-files__remove",onClick:()=>h({downloads:E.filter((e,t)=>t!==n)}),"aria-label":(0,a.__)("删除资源","jio")},(0,e.createElement)("i",{className:"fa far fa-trash-alt","aria-hidden":"true"}))))),s.length>0&&(0,e.createElement)("details",{className:"jio-creator-reuse"},(0,e.createElement)("summary",null,(0,a.__)("从已上传资料中选择","jio")),(0,e.createElement)("ul",null,s.filter(e=>!E.some(t=>t.assetKey===e.assetKey)).map(t=>(0,e.createElement)("li",{key:t.assetKey},(0,e.createElement)("span",null,t.fileName),(0,e.createElement)("span",{className:"jio-creator-muted"},t.sizeLabel),(0,e.createElement)("button",{type:"button",onClick:()=>h({enabled:!0,downloads:[...E,{...t,type:"protected",assetKey:t.assetKey}]})},(0,a.__)("使用","jio"))))))),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("请确保正文里已用「隐藏内容」标注了付费可见的片段。","jio"))),f&&(0,e.createElement)(l,{row:f.row,buttonClasses:v,onPickAttachment:_,onSubmit:e=>{var t;const a=null!==(t=f?.index)&&void 0!==t?t:-1,n=a>=0?E.map((t,n)=>n===a?e:t):[...E,e];b(null),h({enabled:!0,downloads:n})},onClose:()=>b(null)}))}const d=window.jioCreatorStudio||{},m=d.nonce||"";function u({draft:r,setDraft:i,capabilities:l,isPublishedEdit:c,onClose:u,privateStorage:p,privateUploads:_}){const[f,b]=(0,t.useState)(""),[g,h]=(0,t.useState)(!1),j=(0,t.useRef)(null),y={freeAllowed:!!d.pay?.freeAllowed,vipManual:!!d.pay?.vipManual,vip1Enabled:!!d.pay?.vip1Enabled,vip2Enabled:!!d.pay?.vip2Enabled,vip1Name:String(d.pay?.vip1Name||""),vip2Name:String(d.pay?.vip2Name||""),pointsEnabled:!!d.pay?.pointsEnabled,downloadClasses:Array.isArray(d.pay?.downloadClasses)?d.pay.downloadClasses:[],currencySymbol:String(d.pay?.currencySymbol||""),priceMin:Number(d.pay?.priceMin||0),priceMax:Number(d.pay?.priceMax||0),pointsMin:Number(d.pay?.pointsMin||0),pointsMax:Number(d.pay?.pointsMax||0)};return(0,e.createElement)("div",{className:"jio-creator-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-pay-title"},(0,e.createElement)("button",{type:"button",className:"jio-creator-drawer__backdrop","aria-label":(0,a.__)("关闭","jio"),onClick:u}),(0,e.createElement)("div",{className:"jio-creator-drawer__panel"},(0,e.createElement)("header",{className:"jio-creator-drawer__head"},(0,e.createElement)("div",null,(0,e.createElement)("h2",{id:"jio-creator-pay-title"},(0,a.__)("付费资源","jio")),(0,e.createElement)("p",{className:"jio-creator-drawer__subtitle"},(0,a.__)("价格、会员价与付费下载资源","jio"))),(0,e.createElement)("button",{type:"button",className:"jio-creator-drawer__close",onClick:u,"aria-label":(0,a.__)("关闭","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,e.createElement)("div",{className:"jio-creator-drawer__body",ref:j},c&&(0,e.createElement)("p",{className:"jio-creator-drawer__note"},(0,a.__)("审核通过前,读者看到的仍然是当前线上版本。","jio")),l.canPay?(0,e.createElement)(s,{pay:r.pay,onChange:e=>i({pay:e}),canDownload:!!l.canPayDownload,privateStorage:p,privateUploads:_,bootstrap:y,onUploadPrivate:async e=>{b(""),h(!0);try{const t=await async function(e,t,a,r={}){const i=new FormData;i.append("file",t),Object.entries(r).forEach(([e,t])=>i.append(e,t));const l=await fetch(e,{method:"POST",credentials:"same-origin",headers:{"X-WP-Nonce":a},body:i}),c=await o(l);if(!l.ok)throw n(c,l.status);return c}(d.creator.privateUrl,e,m,{post_id:String(r.postId||0)});return{type:"protected",assetKey:String(t.asset_key||""),fileName:String(t.name||e.name),sizeBytes:Number(t.size||e.size),sizeLabel:String(t.size_label||""),label:""}}catch(e){return b(String(e?.message||(0,a.__)("资料上传失败","jio"))),null}finally{h(!1)}},uploading:g,uploadError:f,onPickAttachment:e=>{const t=window.JioSubmitMedia;t&&"function"==typeof t.open?t.open({type:"file",multiple:!1,allowExternal:!1,onSelect:t=>{const a=Array.isArray(t)?t[0]:t;a&&e(String(a.url||""),Number(a.attachment_id||a.id||0))}}):b((0,a.__)("媒体选择器尚未加载,请刷新页面后重试。","jio"))}}):(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("当前账号不能设置付费内容。","jio"))),(0,e.createElement)("footer",{className:"jio-creator-drawer__foot"},(0,e.createElement)("div",{className:"jio-creator-drawer__actions"},(0,e.createElement)("button",{type:"button",className:"jio-creator-primary",onClick:u},(0,a.__)("完成","jio"))))))}function p({canPublishNow:n,isPublishedEdit:o,captcha:r,saving:i,canSubmit:l,onClose:c,onSaveDraft:s,onSubmit:d}){const m=(0,t.useRef)(null);return(0,t.useEffect)(()=>{const e=m.current,t=document.getElementById("jio-creator-captcha");if(!e||!t)return;const a=t.parentElement;return e.appendChild(t),t.removeAttribute("hidden"),()=>{a&&(a.appendChild(t),t.setAttribute("hidden",""))}},[]),(0,t.useEffect)(()=>{const e=e=>{"Escape"!==e.key||i||(e.preventDefault(),c())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,i]),(0,e.createElement)("div",{className:"jio-creator-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-publish-title"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__backdrop","aria-label":(0,a.__)("关闭","jio"),onClick:c}),(0,e.createElement)("div",{className:"jio-creator-dialog__panel"},(0,e.createElement)("header",{className:"jio-creator-dialog__head"},(0,e.createElement)("h2",{id:"jio-creator-publish-title"},o?(0,a.__)("提交改稿","jio"):(0,a.__)("发布文章","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__close",onClick:c,"aria-label":(0,a.__)("关闭","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,e.createElement)("div",{className:"jio-creator-dialog__body"},o&&(0,e.createElement)("p",{className:"jio-creator-dialog__note"},(0,a.__)("审核通过前,读者看到的仍然是当前线上版本。","jio")),r?(0,e.createElement)("div",{className:"jio-creator-dialog__captcha",ref:m}):(0,e.createElement)("p",{className:"jio-creator-muted"},o?(0,a.__)("确认后将提交这份改稿等待审核。","jio"):n?(0,a.__)("确认后立即发布这篇文章。","jio"):(0,a.__)("确认后将提交审核,通过后才会发布。","jio"))),(0,e.createElement)("footer",{className:"jio-creator-dialog__foot"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__ghost",onClick:s,disabled:i},(0,a.__)("保存草稿","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__primary",onClick:()=>d(!1),disabled:i||!l},o?(0,a.__)("提交审核","jio"):n?(0,a.__)("发布","jio"):(0,a.__)("提交审核","jio")),n&&(0,e.createElement)("button",{type:"button",className:"jio-creator-link",onClick:()=>d(!0),disabled:i||!l},(0,a.__)("立即发布","jio")))))}function _({label:a,icon:n,items:o,ready:r,title:i,active:l=!1,width:c=216,onRememberSelection:s}){const[d,m]=(0,t.useState)(!1),u=(0,t.useRef)(null),p=(0,t.useRef)(null),[_,f]=(0,t.useState)({left:0,top:0,placement:"bottom"});(0,t.useLayoutEffect)(()=>{if(!d)return;const e=()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect(),a=p.current?.offsetHeight||240,n=t.bottom+8+a>window.innerHeight&&t.top>a?"top":"bottom",o=Math.min(Math.max(8,t.left+t.width/2-c/2),Math.max(8,window.innerWidth-c-8)),r="bottom"===n?t.bottom+8:t.top-a-8;f({left:o,top:r,placement:n})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[d,c]),(0,t.useEffect)(()=>{if(!d)return;const e=e=>{const t=e.target;u.current?.contains(t)||p.current?.contains(t)||m(!1)},t=e=>{"Escape"===e.key&&(m(!1),u.current?.focus())},a=()=>m(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),window.addEventListener("scroll",a,!0),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t),window.removeEventListener("scroll",a,!0)}},[d]);const b=d?(0,t.createPortal)((0,e.createElement)("div",{ref:p,className:`jio-creator__menu is-${_.placement}`,style:{left:`${_.left}px`,top:`${_.top}px`,width:`${c}px`},role:"menu","aria-label":i||a},o.map(t=>(0,e.createElement)("button",{key:t.key,type:"button",role:"menuitemradio","aria-checked":t.active?"true":"false",className:"jio-creator__menu-item"+(t.active?" is-active":""),onMouseDown:e=>e.preventDefault(),onClick:()=>{m(!1),t.onSelect()}},t.swatch?(0,e.createElement)("span",{className:"jio-creator__menu-swatch",style:{background:t.swatch},"aria-hidden":"true"}):(0,e.createElement)("i",{className:`${t.icon||"fa fas fa-check"} jio-creator__menu-icon`,"aria-hidden":"true"}),(0,e.createElement)("span",{className:"jio-creator__menu-text"},(0,e.createElement)("span",{className:"jio-creator__menu-label"},t.label),t.hint&&(0,e.createElement)("span",{className:"jio-creator__menu-hint"},t.hint)),(0,e.createElement)("i",{className:"fa fas fa-check jio-creator__menu-check","aria-hidden":"true"})))),document.body):null;return(0,e.createElement)("div",{className:"jio-creator__tool-menu"},(0,e.createElement)("button",{ref:u,type:"button",className:`jio-creator__tool-btn${l?" is-active":""}${d?" is-open":""}`,disabled:!r,onClick:()=>{s?.(),m(e=>!e)},title:i||a,"aria-label":i||a,"aria-haspopup":"menu","aria-expanded":d?"true":"false"},(0,e.createElement)("i",{className:n,"aria-hidden":"true"}),(0,e.createElement)("span",{className:"jio-creator__tool-label"},a),(0,e.createElement)("i",{className:"fa fas fa-caret-down jio-creator__tool-caret","aria-hidden":"true"})),b)}function f({label:t,icon:a,ready:n,onClick:o,title:r,active:i=!1}){return(0,e.createElement)("button",{type:"button",className:"jio-creator__tool-btn"+(i?" is-active":""),disabled:!n,onClick:o,title:r||t,"aria-label":r||t,"aria-pressed":i||void 0},(0,e.createElement)("i",{className:a,"aria-hidden":"true"}),(0,e.createElement)("span",{className:"jio-creator__tool-label"},t))}const b=[{key:"",label:(0,a.__)("灰色引用","jio"),swatch:"#555555"},{key:"qe_wzk_c-red",label:(0,a.__)("红色引用","jio"),swatch:"#dc3f3f"},{key:"qe_wzk_lan",label:(0,a.__)("蓝色引用","jio"),swatch:"#0092ff"},{key:"qe_wzk_lv",label:(0,a.__)("绿色引用","jio"),swatch:"#23790e"}],g=[{key:"reply",label:(0,a.__)("评论后可查看","jio"),icon:"fa fas fa-comment-dots"},{key:"login",label:(0,a.__)("登录后可查看","jio"),icon:"fa fas fa-sign-in-alt"},{key:"vip",label:(0,a.__)("会员可查看","jio"),icon:"fa fas fa-crown"},{key:"payshow",label:(0,a.__)("付费后可查看","jio"),icon:"fa fas fa-coins"}];function h({ready:t,canUndo:n,canRedo:o,formatValue:r,onFormatChange:i,alignValue:l,blockValue:c,capabilities:s,onCommand:d,onRememberSelection:m,onOpenLink:u,onOpenMedia:p,onInsertBlock:h,onInsertQuote:j,onInsertHidden:y}){const v=[{key:"p",label:(0,a.__)("正文","jio"),icon:"fa fas fa-paragraph"},{key:"h2",label:(0,a.__)("标题 2","jio"),icon:"fa fas fa-heading"},{key:"h3",label:(0,a.__)("标题 3","jio"),icon:"fa fas fa-heading"},{key:"h4",label:(0,a.__)("标题 4","jio"),icon:"fa fas fa-heading"}].map(e=>({...e,active:r===e.key,onSelect:()=>{i(e.key),d("format",e.key)}})),E=[{key:"ul",label:(0,a.__)("无序列表","jio"),icon:"fa fas fa-list-ul"},{key:"ol",label:(0,a.__)("有序列表","jio"),icon:"fa fas fa-list-ol"}].map(e=>({...e,active:c===e.key,onSelect:()=>h(e.key)})),k=[{key:"left",label:(0,a.__)("居左对齐","jio"),icon:"fa fas fa-align-left"},{key:"center",label:(0,a.__)("居中对齐","jio"),icon:"fa fas fa-align-center"},{key:"right",label:(0,a.__)("居右对齐","jio"),icon:"fa fas fa-align-right"}].map(e=>({...e,active:l===e.key,onSelect:()=>d("align",e.key)})),N=b.map(e=>({key:e.key||"default",label:e.label,swatch:e.swatch,active:c===(e.key||"quote"),onSelect:()=>j(e.key)})),w=g.map(e=>({key:e.key,label:e.label,icon:e.icon,onSelect:()=>y(e.key)})),C="center"===l?"fa fas fa-align-center":"right"===l?"fa fas fa-align-right":"fa fas fa-align-left",S="ol"===c?"fa fas fa-list-ol":"fa fas fa-list-ul";return(0,e.createElement)("div",{className:"jio-creator__toolbar-tools",role:"toolbar","aria-label":(0,a.__)("正文编辑工具","jio"),onMouseDown:e=>{m(),e.target.closest("button")&&e.preventDefault()}},(0,e.createElement)("div",{className:"jio-creator__toolbar-group",role:"group","aria-label":(0,a.__)("撤销和重做","jio")},(0,e.createElement)(f,{label:(0,a.__)("撤销","jio"),icon:"fa fas fa-undo",ready:n,onClick:()=>d("undo")}),(0,e.createElement)(f,{label:(0,a.__)("重做","jio"),icon:"fa fas fa-redo",ready:o,onClick:()=>d("redo")})),(0,e.createElement)("span",{className:"jio-creator__toolbar-divider","aria-hidden":"true"}),(0,e.createElement)("div",{className:"jio-creator__toolbar-group",role:"group","aria-label":(0,a.__)("段落样式","jio")},(0,e.createElement)(_,{label:(0,a.__)("标题","jio"),icon:"fa fas fa-heading",items:v,ready:t,width:168,onRememberSelection:m})),(0,e.createElement)("span",{className:"jio-creator__toolbar-divider","aria-hidden":"true"}),(0,e.createElement)("div",{className:"jio-creator__toolbar-group",role:"group","aria-label":(0,a.__)("文字格式","jio")},(0,e.createElement)(f,{label:(0,a.__)("加粗","jio"),icon:"fa fas fa-bold",ready:t,onClick:()=>d("Bold")}),(0,e.createElement)(f,{label:(0,a.__)("斜体","jio"),icon:"fa fas fa-italic",ready:t,onClick:()=>d("Italic")}),(0,e.createElement)(f,{label:(0,a.__)("下划线","jio"),icon:"fa fas fa-underline",ready:t,onClick:()=>d("Underline")})),(0,e.createElement)("span",{className:"jio-creator__toolbar-divider","aria-hidden":"true"}),(0,e.createElement)("div",{className:"jio-creator__toolbar-group",role:"group","aria-label":(0,a.__)("段落块","jio")},(0,e.createElement)(_,{label:(0,a.__)("列表","jio"),icon:S,items:E,ready:t,width:168,onRememberSelection:m,active:"ul"===c||"ol"===c}),(0,e.createElement)(_,{label:(0,a.__)("对齐","jio"),icon:C,items:k,ready:t,width:168,onRememberSelection:m,active:"left"!==l,title:(0,a.__)("对齐方式","jio")}),(0,e.createElement)(_,{label:(0,a.__)("引用","jio"),icon:"fa fas fa-quote-left",items:N,ready:t,width:168,onRememberSelection:m,active:"quote"===c||b.some(e=>e.key===c)}),s.canHide&&(0,e.createElement)(_,{label:(0,a.__)("隐藏","jio"),icon:"fa fas fa-eye-slash",items:w,ready:t,width:190,onRememberSelection:m,title:(0,a.__)("隐藏内容","jio")}),(0,e.createElement)(f,{label:(0,a.__)("分割线","jio"),icon:"fa fas fa-minus",ready:t,onClick:()=>h("divider")}),(0,e.createElement)(f,{label:(0,a.__)("代码块","jio"),icon:"fa fas fa-code",ready:t,onClick:()=>h("code")}),(0,e.createElement)(f,{label:(0,a.__)("注释","jio"),icon:"fa fas fa-comment-dots",ready:t,onClick:()=>h("footnote")}),(0,e.createElement)(f,{label:(0,a.__)("公式","jio"),icon:"fa fas fa-square-root-alt",ready:t,onClick:()=>h("math")}),(0,e.createElement)(f,{label:(0,a.__)("表格","jio"),icon:"fa fas fa-table",ready:t,onClick:()=>h("table")})),(0,e.createElement)("span",{className:"jio-creator__toolbar-divider","aria-hidden":"true"}),(0,e.createElement)("div",{className:"jio-creator__toolbar-group",role:"group","aria-label":(0,a.__)("媒体和链接","jio")},s.canUploadImage&&(0,e.createElement)(f,{label:(0,a.__)("图片","jio"),icon:"fa far fa-image",ready:t,onClick:()=>p("image")}),(s.canUploadVideo||s.canEmbed)&&(0,e.createElement)(f,{label:(0,a.__)("视频","jio"),icon:"fa fas fa-video",ready:t,onClick:()=>p("video")}),(0,e.createElement)(f,{label:(0,a.__)("链接","jio"),icon:"fa fas fa-link",ready:t,onClick:u}),s.canUploadFile&&(0,e.createElement)(f,{label:(0,a.__)("附件","jio"),icon:"fa fas fa-paperclip",ready:t,onClick:()=>p("file")})))}const j=window.jioCreatorStudio||{},y=(j.nonce,e=>String(e).padStart(2,"0"));function v(e){return`${e.getFullYear()}-${y(e.getMonth()+1)}-${y(e.getDate())}T${y(e.getHours())}:${y(e.getMinutes())}`}function E({featured:n,canEditCover:o,canSchedule:r,scheduleEnabled:i,scheduleAt:l,pay:c,canPay:s,taxonomy:d,categories:m,tags:u,custom:p,onFeaturedChange:_,onScheduleChange:f,onPayEnabledChange:b,onCategoriesChange:g,onTagsChange:h,onCustomChange:y,onOpenPaySettings:E}){const[k,N]=(0,t.useState)(""),[w,C]=(0,t.useState)(""),S=(0,t.useMemo)(()=>v(new Date(Date.now()+3e5)),[]),x="string"==typeof n?.data?.url?n.data.url:"",M=()=>{const e=k.trim();if(!e)return;const t=e.split(/[,,\n]+/u).map(e=>e.trim()).filter(Boolean);h(Array.from(new Set([...u,...t]))),N("")},L=()=>{const e=window.JioSubmitMedia;e&&"function"==typeof e.open?(C(""),e.open({type:"image",multiple:!1,onSelect:e=>{const t=Array.isArray(e)?e[0]:e;if(!t)return;const n=String(t.url||t.large_url||"");if(!n)return void C((0,a.__)("无法读取图片地址,请重新选择。","jio"));const o=Number(t.attachment_id||t.id||0);_({type:"image",mediaId:o,data:{id:o,url:n}})}})):C((0,a.__)("媒体选择器尚未加载,请刷新页面后重试。","jio"))};return(0,e.createElement)("section",{className:"jio-creator__settings","aria-label":(0,a.__)("发布设置","jio")},(0,e.createElement)("h2",{className:"jio-creator__settings-title"},(0,a.__)("发布设置","jio")),(0,e.createElement)("div",{className:"jio-creator__setting-row jio-creator__setting-row--stack"},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},(0,a.__)("分类","jio")),(0,e.createElement)("p",{className:"jio-creator__setting-help"},(0,a.__)("必选,决定文章出现在哪些栏目。","jio"))),(0,e.createElement)("div",{className:"jio-creator-chips"},0===d.categories.length&&(0,e.createElement)("span",{className:"jio-creator-muted"},(0,a.__)("暂无可选分类","jio")),d.categories.map(t=>(0,e.createElement)("label",{key:t.id,className:"jio-creator-chip"+(m.includes(t.id)?" is-active":"")},(0,e.createElement)("input",{type:"checkbox",checked:m.includes(t.id),onChange:()=>{return e=t.id,void g(m.includes(e)?m.filter(t=>t!==e):[...m,e]);var e}}),(0,e.createElement)("span",null,t.name))))),d.tags&&(0,e.createElement)("div",{className:"jio-creator__setting-row jio-creator__setting-row--stack"},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},(0,a.__)("标签","jio")),(0,e.createElement)("p",{className:"jio-creator__setting-help"},(0,a.__)("多个标签用逗号分隔,回车即可添加。","jio"))),(0,e.createElement)("div",null,u.length>0&&(0,e.createElement)("div",{className:"jio-creator-chips"},u.map(t=>(0,e.createElement)("span",{key:t,className:"jio-creator-chip is-active"},(0,e.createElement)("span",null,t),(0,e.createElement)("button",{type:"button",onClick:()=>h(u.filter(e=>e!==t)),"aria-label":(0,a.sprintf)((0,a.__)("移除标签 %s","jio"),t)},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))))),(0,e.createElement)("div",{className:"jio-creator-inline"},(0,e.createElement)("input",{type:"text",value:k,placeholder:(0,a.__)("输入标签,逗号分隔","jio"),onChange:e=>N(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),M())}}),(0,e.createElement)("button",{type:"button",onClick:M},(0,a.__)("添加","jio"))))),d.customDefs.map(t=>(0,e.createElement)("div",{className:"jio-creator__setting-row jio-creator__setting-row--stack",key:t.key},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},t.name)),(0,e.createElement)("div",{className:"jio-creator-chips"},t.values.map(a=>{const n=(p[t.key]||[]).includes(a.key);return(0,e.createElement)("label",{key:a.key,className:"jio-creator-chip"+(n?" is-active":"")},(0,e.createElement)("input",{type:"checkbox",checked:n,onChange:()=>((e,t)=>{const a=p[e]||[];y({...p,[e]:a.includes(t)?a.filter(e=>e!==t):[...a,t]})})(t.key,a.key)}),(0,e.createElement)("span",null,a.name))})))),o&&(0,e.createElement)("div",{className:"jio-creator__setting-row"},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},(0,a.__)("添加封面","jio")),(0,e.createElement)("p",{className:"jio-creator__setting-help"},(0,a.__)("用于列表卡片、分享卡片;不设置时自动使用正文首图。","jio"))),(0,e.createElement)("div",{className:"jio-creator__cover-control"},x?(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{type:"button",className:"jio-creator__cover-preview",onClick:L,"aria-label":(0,a.__)("更换封面","jio")},(0,e.createElement)("img",{src:x,alt:""})),(0,e.createElement)("button",{type:"button",className:"jio-creator__cover-clear",onClick:()=>_({type:"",data:{}}),"aria-label":(0,a.__)("移除封面","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))):(0,e.createElement)("button",{type:"button",className:"jio-creator__cover-add",onClick:L},(0,e.createElement)("i",{className:"fa fas fa-plus","aria-hidden":"true"}),(0,e.createElement)("span",null,(0,a.__)("添加封面","jio"))))),w&&(0,e.createElement)("p",{className:"jio-creator-error"},w),s&&(0,e.createElement)("div",{className:"jio-creator__setting-row"},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},(0,a.__)("付费内容","jio")),(0,e.createElement)("p",{className:"jio-creator__setting-help"},c.enabled?c.downloads.length>0?(0,a.sprintf)(/* translators: %d: number of paid download resources */ /* translators: %d: number of paid download resources */
(0,a.__)("已开启,含 %d 个付费下载资源。","jio"),c.downloads.length):(0,a.__)("已开启,未购买读者只能看到免费部分。","jio"):(0,a.__)("开启后可以设置价格、会员价并添加付费下载资源。","jio")),c.enabled&&(0,e.createElement)("button",{type:"button",className:"jio-creator__setting-link",onClick:E},(0,e.createElement)("i",{className:"fa fas fa-coins","aria-hidden":"true"}),(0,a.__)("配置价格与付费资源","jio"))),(0,e.createElement)("label",{className:"jio-creator-toggle"},(0,e.createElement)("input",{type:"checkbox",checked:c.enabled,onChange:e=>{const t=e.target.checked;b(t),t&&E()}}),(0,e.createElement)("span",{"aria-hidden":"true"}))),(0,e.createElement)("div",{className:"jio-creator__setting-row"},(0,e.createElement)("div",{className:"jio-creator__setting-copy"},(0,e.createElement)("span",{className:"jio-creator__setting-label"},(0,a.__)("定时发布","jio")),(0,e.createElement)("p",{className:"jio-creator__setting-help"},r?(0,a.__)("开启后到点自动发布,发布前不会出现在文章列表。","jio"):(0,a.__)("当前账号提交后需要审核,审核通过后才会发布。","jio"))),(0,e.createElement)("label",{className:"jio-creator-toggle"},(0,e.createElement)("input",{type:"checkbox",checked:i,disabled:!r,onChange:e=>f(e.target.checked,l||v(new Date(Date.now()+36e5)))}),(0,e.createElement)("span",{"aria-hidden":"true"}))),r&&i&&(0,e.createElement)("div",{className:"jio-creator__schedule"},(0,e.createElement)("label",null,(0,e.createElement)("span",null,(0,a.__)("发布时间","jio")),(0,e.createElement)("input",{type:"datetime-local",value:l,min:S,onChange:e=>f(!0,e.target.value)})),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.sprintf)(/* translators: %s: site timezone */ /* translators: %s: site timezone */
(0,a.__)("按站点时区(%s)发布,至少需要晚于当前时间 1 分钟。","jio"),String(j.timezone||"UTC")))))}function k({centerUrl:t,site:n,viewer:o}){const r=String(n.name||""),i=String(o.avatar||""),l=t||"/";return(0,e.createElement)("header",{className:"jio-creator__masthead"},(0,e.createElement)("div",{className:"jio-creator__masthead-left"},(0,e.createElement)("a",{className:"jio-creator__back",href:t||"/","aria-label":(0,a.__)("返回作者中心","jio")},(0,e.createElement)("i",{className:"fa fas fa-angle-left","aria-hidden":"true"})),(0,e.createElement)("a",{className:"jio-creator__brand",href:String(n.home||"/"),"aria-label":r||(0,a.__)("返回首页","jio")},n.logo?(0,e.createElement)("img",{className:"jio-creator__brand-logo",src:String(n.logo),alt:r}):(0,e.createElement)("span",{className:"jio-creator__brand-text"},r))),(0,e.createElement)("a",{className:"jio-creator__me",href:l,"aria-label":(0,a.__)("返回作者中心","jio")},i?(0,e.createElement)("img",{className:"jio-creator__me-avatar",src:i,alt:"",width:32,height:32}):(0,e.createElement)("span",{className:"jio-creator__me-avatar is-placeholder","aria-hidden":"true"},(0,e.createElement)("i",{className:"fa fas fa-user"}))))}function N(e){const t=(e.downloads||[]).map(e=>{const t="string"==typeof e.label?e.label:"",a="string"==typeof e.assetKey?e.assetKey:"";if(a)return{type:"protected",asset_key:a,label:t};const n="string"==typeof e.url?e.url.trim():"";return n?{type:"net_disk"===e.type?"net_disk":"direct",url:n,label:t,extract_code:"string"==typeof e.extractCode?e.extractCode:"",copy_key:"string"==typeof e.copyKey?e.copyKey:"",copy_val:"string"==typeof e.copyVal?e.copyVal:"",class:"string"==typeof e.class?e.class:"",attachment_id:Math.max(0,Number(e.attachmentId)||0)}:null}).filter(Boolean),a="points"===e.modo;return{enabled:!!e.enabled,fields:{pay_type:e.enabled?t.length>0?"download":"reading":"no",pay_modo:a?"points":"0",price:a?"0.00":String(e.price||"0.00"),points_price:a?Math.max(0,Number(e.points)||0):0,vip1_price:a?"0.00":String(e.vip1Price||"0.00"),vip2_price:a?"0.00":String(e.vip2Price||"0.00"),vip1_points:a?Math.max(0,Number(e.vip1Points)||0):0,vip2_points:a?Math.max(0,Number(e.vip2Points)||0):0,pay_limit:Number(e.payLimit)||0,downloads:t}}}const w=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function C(e){if(!e||-1===e.indexOf("data-jio-"))return e;const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("[data-jio-math-source]").forEach(e=>{const t=e.getAttribute("data-jio-math-source")||"",a="0"!==e.getAttribute("data-jio-math-display"),n=`[jio_math display="${a?"1":"0"}"]${t}[/jio_math]`,o=e.closest("p");a&&o&&o.textContent?.trim()===e.textContent?.trim()?o.textContent=n:e.replaceWith(document.createTextNode(n))}),t.querySelectorAll("[data-jio-footnote]").forEach(e=>{const t=e.getAttribute("data-jio-footnote")||"";e.replaceWith(document.createTextNode(`[jio_footnote]${t}[/jio_footnote]`))}),t.innerHTML}function S(e){return e&&-1!==e.indexOf("[jio_")?e.replace(/\[jio_math display="([01])"\]([\s\S]*?)\[\/jio_math\]/g,(e,t,a)=>"0"===t?`<span class="jio-math" data-jio-math-source="${w(a)}" data-jio-math-display="0" contenteditable="false">${x(a)}</span>`:`<p><span class="jio-math jio-math--block" data-jio-math-source="${w(a)}" data-jio-math-display="1" contenteditable="false">${x(a)}</span></p>`).replace(/\[jio_footnote\]([\s\S]*?)\[\/jio_footnote\]/g,(e,t)=>`<sup class="jio-footnote-ref" data-jio-footnote="${w((e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(t))}" contenteditable="false">${t}</sup>`):e}const x=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\^\{([^{}]*)\}|\^(\S)/gu,"<sup>$1$2</sup>").replace(/_\{([^{}]*)\}|_(\S)/gu,"<sub>$1$2</sub>"),M={ready:(0,a.__)("尚未保存","jio"),saving:(0,a.__)("保存中…","jio"),saved:(0,a.__)("已保存","jio"),error:(0,a.__)("保存失败","jio"),conflict:(0,a.__)("内容已在别处更新","jio"),submitting:(0,a.__)("提交中…","jio"),submitted:(0,a.__)("已提交","jio")};function L({value:t}){return(0,e.createElement)("span",{className:`jio-creator__save is-${t.state}`,role:"status","aria-live":"polite"},(0,e.createElement)("i",{className:"fa fas fa-circle","aria-hidden":"true"}),(0,e.createElement)("span",null,M[t.state]||M.ready),"saved"===t.state&&t.at?(0,e.createElement)("time",null,t.at):null)}const $=36e5,P=24*$,q=30*P,I=365*P,R={ready:(0,a.__)("草稿","jio"),saving:(0,a.__)("保存中","jio"),saved:(0,a.__)("草稿","jio"),error:(0,a.__)("保存失败","jio"),conflict:(0,a.__)("冲突","jio"),submitting:(0,a.__)("提交中","jio"),submitted:(0,a.__)("已提交","jio")};function D({charCount:t,saveState:n,isPublishedEdit:o,saving:r,onSaveDraft:i,onPreview:l,onPublish:c}){const s=n.at?function(e,t=Date.now()){const n=Date.parse(e);if(!Number.isFinite(n))return"";const o=Math.max(0,t-n);return o<6e4?(0,a.__)("刚刚","jio"):o<$?(0,a.sprintf)(/* translators: %d: minutes */ /* translators: %d: minutes */
(0,a.__)("%d分钟前","jio"),Math.floor(o/6e4)):o<P?(0,a.sprintf)(/* translators: %d: hours */ /* translators: %d: hours */
(0,a.__)("%d小时前","jio"),Math.floor(o/$)):o<q?(0,a.sprintf)(/* translators: %d: days */ /* translators: %d: days */
(0,a.__)("%d天前","jio"),Math.floor(o/P)):o<I?(0,a.sprintf)(/* translators: %d: months */ /* translators: %d: months */
(0,a.__)("%d个月前","jio"),Math.floor(o/q)):(0,a.sprintf)(/* translators: %d: years */ /* translators: %d: years */
(0,a.__)("%d年前","jio"),Math.floor(o/I))}(n.at):"",d=R[n.state]||R.ready;return(0,e.createElement)("footer",{className:"jio-creator__status",role:"contentinfo"},(0,e.createElement)("div",{className:"jio-creator__status-left"},(0,e.createElement)("span",{className:"jio-creator__status-count"},(0,a.__)("字数","jio"),":",t),(0,e.createElement)("span",{className:"jio-creator__status-mode"},(0,a.__)("Markdown 语法输入中","jio"))),(0,e.createElement)("div",{className:"jio-creator__status-meta"},(0,e.createElement)(L,{value:n}),(0,e.createElement)("span",{className:"jio-creator__status-dot","aria-hidden":"true"},"·"),(0,e.createElement)("span",{className:"jio-creator__status-time"},s||d)),(0,e.createElement)("div",{className:"jio-creator__status-actions"},(0,e.createElement)("button",{type:"button",className:"jio-creator__status-ghost",onClick:i,disabled:r},(0,a.__)("保存草稿","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator__status-ghost",onClick:l,disabled:r},(0,a.__)("预览","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator__status-primary",onClick:c,disabled:r},o?(0,a.__)("提交改稿","jio"):(0,a.__)("发布","jio"))))}const z=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),A=/<(?:p|div|h[1-6]|ul|ol|li|blockquote|pre|table|figure|section)\b/i,U=e=>{const t=e.trim();return""===t?"<p></p>":A.test(t)?t:`<p>${t}</p>`};const V={reply:{open:"[reply]",close:"[/reply]",label:(0,a.__)("评论后可查看","jio")},login:{open:'[jio_hide mode="login"]',close:"[/jio_hide]",label:(0,a.__)("登录后可查看","jio")},vip:{open:"[vip]",close:"[/vip]",label:(0,a.__)("会员可查看","jio")},payshow:{open:"[payshow]",close:"[/payshow]",label:(0,a.__)("付费后可查看","jio")}},T=(e,t,a)=>Math.min(a,Math.max(t,Number.isFinite(e)?Math.round(e):t)),B={table:(0,a.__)("插入表格","jio"),math:(0,a.__)("插入公式","jio"),footnote:(0,a.__)("插入注释","jio")};function K({kind:n,onSubmit:o,onClose:r}){const[i,l]=(0,t.useState)(3),[c,s]=(0,t.useState)(3),[d,m]=(0,t.useState)(!0),[u,p]=(0,t.useState)(!1),[_,f]=(0,t.useState)("a^2 + b^2 = c^2"),[b,g]=(0,t.useState)(!0),[h,j]=(0,t.useState)(""),y=(0,t.useRef)(null),v=(0,t.useRef)(null),E=(0,t.useRef)(null),k=(0,t.useRef)(null);(0,t.useEffect)(()=>{(v.current||E.current||k.current)?.focus();const e=e=>{"Escape"===e.key&&(e.preventDefault(),r())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]);const N=(0,t.useMemo)(()=>"footnote"===n?""!==h.trim():"math"!==n||""!==_.trim(),[n,h,_]);return(0,e.createElement)("div",{className:"jio-creator-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-dialog-title"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__backdrop","aria-label":(0,a.__)("关闭","jio"),onClick:r}),(0,e.createElement)("div",{className:"jio-creator-dialog__panel",ref:y},(0,e.createElement)("header",{className:"jio-creator-dialog__head"},(0,e.createElement)("h2",{id:"jio-creator-dialog-title"},B[n]),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__close",onClick:r,"aria-label":(0,a.__)("关闭","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,e.createElement)("div",{className:"jio-creator-dialog__body"},"table"===n&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"jio-creator-dialog__row"},(0,e.createElement)("label",null,(0,e.createElement)("span",null,(0,a.__)("行数","jio")),(0,e.createElement)("input",{ref:v,type:"number",min:1,max:20,value:i,onChange:e=>l(Number(e.target.value))})),(0,e.createElement)("label",null,(0,e.createElement)("span",null,(0,a.__)("列数","jio")),(0,e.createElement)("input",{type:"number",min:1,max:10,value:c,onChange:e=>s(Number(e.target.value))}))),(0,e.createElement)("label",{className:"jio-creator-dialog__check"},(0,e.createElement)("input",{type:"checkbox",checked:d,onChange:e=>m(e.target.checked)}),(0,e.createElement)("span",null,(0,a.__)("首行为表头","jio"))),(0,e.createElement)("label",{className:"jio-creator-dialog__check"},(0,e.createElement)("input",{type:"checkbox",checked:u,onChange:e=>p(e.target.checked)}),(0,e.createElement)("span",null,(0,a.__)("隔行变色","jio")))),"math"===n&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("label",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("公式","jio")),(0,e.createElement)("textarea",{ref:E,rows:3,value:_,onChange:e=>f(e.target.value),placeholder:"a^2 + b^2 = c^2"})),(0,e.createElement)("p",{className:"jio-creator-muted"},(0,a.__)("支持上标 ^ 与下标 _,例如 x^2 与 a_n;暂不支持完整 LaTeX。","jio")),(0,e.createElement)("label",{className:"jio-creator-dialog__check"},(0,e.createElement)("input",{type:"checkbox",checked:b,onChange:e=>g(e.target.checked)}),(0,e.createElement)("span",null,(0,a.__)("独占一行显示","jio")))),"footnote"===n&&(0,e.createElement)("label",{className:"jio-creator-dialog__field"},(0,e.createElement)("span",null,(0,a.__)("注释内容","jio")),(0,e.createElement)("textarea",{ref:k,rows:4,value:h,onChange:e=>j(e.target.value),placeholder:(0,a.__)("填写要补充说明的内容","jio")}))),(0,e.createElement)("footer",{className:"jio-creator-dialog__foot"},(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__ghost",onClick:r},(0,a.__)("取消","jio")),(0,e.createElement)("button",{type:"button",className:"jio-creator-dialog__primary",onClick:()=>{N&&o("table"!==n?"math"!==n?{kind:n,note:h.trim()}:{kind:n,formula:_.trim(),display:b}:{kind:n,rows:T(i,1,20),cols:T(c,1,10),header:d,striped:u})},disabled:!N},(0,a.__)("插入","jio")))))}const F="table,pre,hr,.quote_q,.tinymce-hide,.jio-math--block";function O(e){if(!e||e.removed)return;const t=e.getDoc(),a=e.getContentAreaContainer()?.querySelector("iframe");if(!t||!a)return;const n=Math.max(320,t.documentElement.scrollHeight,t.body?t.body.scrollHeight:0);a.style.height=`${n}px`,a.style.overflow="hidden"}const H="jio-creator__block-selected",J=window.jioCreatorStudio||{},W=J.nonce||"",X=`jio-studio-${J.sourceId||0}`,Y="jio-creator-content";function Q(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function G(e){const t=String(e||"").trim();if(!t)return"";try{const e=new URL(t,window.location.href);return"http:"===e.protocol||"https:"===e.protocol?e.href:""}catch(e){return""}}function Z(e){const t=document.createElement("div");return t.innerHTML=e,(t.textContent||"").replace(/\s+/g,"")}function ee(){const[n,o]=(0,t.useState)(()=>function(e){const t=e.pay||{},a=e.categories&&e.categories.selected||[],n=e.tags&&e.tags.items||[];return{postId:Number(e.sourceId||0),versionId:Number(e.versionId||0),rev:Number(e.versionRev||0),title:String(e.title||""),content:String(e.content||""),schedule:{enabled:!1,at:""},categories:a.map(Number),tags:n.slice(),custom:e.custom||{},featured:e.featured||{type:"",data:{}},pay:{enabled:!!t.enabled,modo:"points"===t.payModo?"points":"cash",price:String(t.price||"0.00"),points:Number(t.points||0),vip1Price:String(t.vip1Price||"0.00"),vip2Price:String(t.vip2Price||"0.00"),vip1Points:Number(t.vip1Points||0),vip2Points:Number(t.vip2Points||0),payLimit:Number(t.payLimit||0),downloads:Array.isArray(t.downloads)?t.downloads:[]}}}(J)),i=(0,t.useRef)(n);i.current=n;const l=(0,t.useRef)(null),c=(0,t.useRef)(null),s=(0,t.useRef)(null),d=(0,t.useRef)(!1),m=(0,t.useRef)(()=>{}),[_,f]=(0,t.useState)(!1),[b,g]=(0,t.useState)({canUndo:!1,canRedo:!1}),[j,y]=(0,t.useState)("p"),[v,w]=(0,t.useState)("left"),[x,M]=(0,t.useState)("p"),[L,$]=(0,t.useState)(()=>({state:J.sourceId||J.versionId||J.content?"saved":"ready",at:""})),[P,q]=(0,t.useState)(!1),[I,R]=(0,t.useState)(!1),[A,T]=(0,t.useState)(null),[B,ee]=(0,t.useState)(null),[te,ae]=(0,t.useState)(null),ne=(0,t.useRef)(!1),oe=(0,t.useRef)(0),re=J.capabilities||{},ie={titleMin:Number(J.limits?.titleMin||1),titleMax:Number(J.limits?.titleMax||30),titlePlaceholder:String(J.limits?.titlePlaceholder||(0,a.__)("请输入标题","jio")),priceMin:Number(J.pay?.priceMin||0),priceMax:Number(J.pay?.priceMax||0),pointsMin:Number(J.pay?.pointsMin||0),pointsMax:Number(J.pay?.pointsMax||0)},le=!!J.isPublished,ce=(0,t.useMemo)(()=>Array.from(Z(n.content)).length,[n.content]),se=(0,t.useCallback)(e=>{ne.current=!0,oe.current+=1;const t={...i.current,...e};i.current=t,o(t)},[]),de=(0,t.useCallback)(e=>{if(e===i.current.content)return;ne.current=!0,oe.current+=1;const t={...i.current,content:e};i.current=t,o(t)},[]),me=(0,t.useCallback)(e=>{const t=e?.undoManager;t&&g({canUndo:"function"==typeof t.hasUndo&&t.hasUndo(),canRedo:"function"==typeof t.hasRedo&&t.hasRedo()})},[]),ue=(0,t.useCallback)(e=>{const t=e?.selection?.getNode(),a=t?e.dom.getParent(t,"p,h1,h2,h3,h4,h5,h6")||t:null,n=a?.nodeName?.toLowerCase()||"p";y(["h1","h2","h3","h4"].includes(n)?n:"p")},[]),pe=(0,t.useCallback)(e=>{const t=e?.selection?.getNode();if(!t)return;const a=e.getBody(),n=String(e.formatter?.match?.(["alignleft","aligncenter","alignright"])||"");w("aligncenter"===n?"center":"alignright"===n?"right":"left");const o=e.dom.getParent(t,".quote_q",a);if(o){const e=Array.from(o.classList).find(e=>0===e.indexOf("qe_wzk_"));return void M(e||"quote")}e.dom.getParent(t,"ul",a)?M("ul"):e.dom.getParent(t,"ol",a)?M("ol"):M("p")},[]),_e=(0,t.useCallback)((e={})=>{const t=i.current;return{post_id:t.postId,version_id:t.versionId,rev:t.rev,title:t.title,content:t.content,categories:t.categories,tags:t.tags,custom:t.custom,featured:t.featured,schedule:{enabled:!!t.schedule.enabled,at:t.schedule.enabled?t.schedule.at:""},pay:N(t.pay),...e}},[]),fe=(0,t.useCallback)(async(e=!1)=>{const t=l.current;t&&!t.removed&&de(C(t.getContent()));const a=i.current;if(!ne.current&&(a.postId>0||a.versionId>0))return!0;const n=oe.current;if(""===a.title.trim()&&""===Z(a.content).trim()&&!/<(?:img|table|pre|hr|iframe|video)/i.test(a.content))return!0;$({state:"saving",at:""});try{const t=await r(J.creator.saveUrl,_e({autosave:e}),W),a={...i.current,postId:Number(t.post_id||i.current.postId||0),versionId:Number(t.version_id||i.current.versionId||0),rev:Number(t.rev||t.versionRev||i.current.rev||0)};window.jioSubmitData&&(window.jioSubmitData.postId=a.postId);const l=oe.current===n;return ne.current=!l,i.current=a,o(a),$({state:l?"saved":"saving",at:l?(new Date).toLocaleTimeString():""}),l}catch(e){return $({state:409===e?.status?"conflict":"error",at:""}),!1}},[_e]);m.current=()=>{fe(!1)};const be=(0,t.useCallback)(async e=>{if(await fe(!1)){$({state:"submitting",at:""});try{let t="";const n=window.JioCaptcha;if(J.captcha?.enabled&&n&&"function"==typeof n.run){const e=await n.run("front_submit");if(null===e)return $({state:"ready",at:""}),void ee({tone:"error",text:(0,a.__)("请先完成人机验证","jio")});t=String(e?.jio_captcha_proof||"")}const o=await r(J.creator.submitUrl,_e({post_id:i.current.postId,version_id:i.current.versionId,rev:i.current.rev,publish_now:e,captcha_proof:t}),W);ne.current=!1,$({state:"submitted",at:""}),ee({tone:"ok",text:String(o.message||(0,a.__)("已提交","jio"))}),R(!1),q(!1);const l=o.url||o.goto||J.urls?.center;l&&window.setTimeout(()=>{window.location.href=l},900)}catch(e){$({state:"error",at:""}),ee({tone:"error",text:String(e?.message||(0,a.__)("提交失败","jio"))})}}else ee({tone:"error",text:(0,a.__)("内容保存失败,请重试后再提交","jio")})},[_e,fe]),ge=(0,t.useCallback)(async()=>{if(await fe(!1))try{const e=await r(J.creator.previewUrl,{post_id:i.current.postId,version_id:i.current.versionId},W);e.url&&window.open(String(e.url),"_blank","noopener")}catch(e){ee({tone:"error",text:String(e?.message||(0,a.__)("预览失败","jio"))})}},[fe]),{markLocalSaved:he,clear:je}=function({key:e,snapshot:a,onFound:n}){const o=(0,t.useRef)(a);o.current=a;const r=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if(!r.current){r.current=!0;try{const t=window.localStorage.getItem(e);if(!t)return;const o=JSON.parse(t),r="string"==typeof o.at?Date.parse(o.at):NaN;if(!Number.isFinite(r)||Date.now()-r>6048e5)return void window.localStorage.removeItem(e);"string"==typeof o.content&&o.content!==a.content&&n(String(o.at))}catch(t){window.localStorage.removeItem(e)}}},[e,n,a.content]),{markLocalSaved:(0,t.useCallback)(()=>{try{window.localStorage.setItem(e,JSON.stringify(o.current))}catch(e){}},[e]),clear:(0,t.useCallback)(()=>{try{window.localStorage.removeItem(e)}catch(e){}},[e])}}({key:X,snapshot:{title:n.title,content:n.content,at:(new Date).toISOString()},onFound:e=>ae({savedAt:e})}),ye=function({enabled:e,onSave:a,onLocal:n,remoteDelay:o=4e3,localDelay:r=1500}){const i=(0,t.useRef)(null),l=(0,t.useRef)(null),c=(0,t.useRef)(!1),s=(0,t.useRef)(a),d=(0,t.useRef)(n);s.current=a,d.current=n;const m=(0,t.useCallback)(()=>{i.current&&(window.clearTimeout(i.current),i.current=null),l.current&&(window.clearTimeout(l.current),l.current=null)},[]),u=(0,t.useCallback)(async()=>{if(!c.current){c.current=!0;try{await s.current()}finally{c.current=!1}}},[]),p=(0,t.useCallback)(()=>{m(),d.current(),e&&(l.current=window.setTimeout(()=>d.current(),r),i.current=window.setTimeout(()=>{u()},o))},[m,e,u,r,o]);return(0,t.useEffect)(()=>{if(!e)return;const t=()=>{"hidden"===document.visibilityState&&u()},a=()=>{u()};return document.addEventListener("visibilitychange",t),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("blur",a),m()}},[m,e,u]),(0,t.useMemo)(()=>({schedule:p,flush:u,cancel:m}),[m,u,p])}({enabled:!!re.isLoggedIn,onSave:async()=>{const e=await fe(!0);return e&&je(),e},onLocal:he}).schedule;(0,t.useEffect)(()=>{ne.current&&ye()},[n,ye]),(0,t.useEffect)(()=>{const e=e=>{ne.current&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),(0,t.useEffect)(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()&&(e.preventDefault(),fe(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[fe]),(0,t.useEffect)(()=>{const e=window.wp?.editor;if(!e||"function"!=typeof e.initialize)return void ee({tone:"error",text:(0,a.__)("TinyMCE 加载失败,请刷新页面后重试。","jio")});const t={quicktags:!1,tinymce:{menubar:!1,statusbar:!1,resize:!1,toolbar1:"",toolbar2:"",toolbar3:"",plugins:"paste,link,lists,wordpress,wplink",wpautop:!0,body_class:"jio-creator__tinymce",content_css:J.creator?.contentCss||"",content_style:'\nbody {\n\tposition: relative;\n\tmargin: 0;\n\tcolor: #2b2b2b;\n\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;\n\tfont-size: 16px;\n\tline-height: 1.8;\n\tletter-spacing: 0.01em;\n}\np { margin: 0 0 1.1em; }\nh1, h2, h3, h4, h5, h6 { margin: 1.5em 0 0.65em; line-height: 1.4; }\nimg, iframe { max-width: 100%; }\nimg { height: auto; }\n\n/*\n * 块级删除控件。它由 editor-runtime 插进 iframe 的 body,样式必须写在这里:\n * 父页面样式表管不到 iframe 内部,缺这条规则时按钮会退化成正文顶部的常显小方块。\n * 正文是流式布局且 iframe 高度随内容增长,所以按整篇正文定位,而不是相对某个块。\n */\n#jio-block-actions {\n\tposition: absolute;\n\tz-index: 5;\n\ttop: 6px;\n\tleft: 6px;\n\topacity: 0;\n\tpointer-events: none;\n\ttransition: opacity 0.15s ease;\n}\n#jio-block-actions.is-visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n#jio-block-actions .jio-creator__block-action {\n\tdisplay: inline-flex;\n\theight: 26px;\n\talign-items: center;\n\tgap: 5px;\n\tpadding: 0 9px;\n\tborder: 1px solid #e3e7e5;\n\tborder-radius: 6px;\n\tbackground: #fff;\n\tcolor: #7d8683;\n\tfont: inherit;\n\tfont-size: 12px;\n\tline-height: 1;\n\twhite-space: nowrap;\n\tbox-shadow: 0 2px 8px rgba(24, 39, 34, 0.08);\n\tcursor: pointer;\n}\n#jio-block-actions .jio-creator__block-action-icon {\n\tfont-size: 11px;\n\tline-height: 1;\n}\n#jio-block-actions .jio-creator__block-action:hover {\n\tborder-color: #cdd6d2;\n\tcolor: #4f5957;\n}\n#jio-block-actions.is-selected .jio-creator__block-action {\n\tborder-color: #e0a99b;\n\tbackground: #fdf2ee;\n\tcolor: #b4573f;\n}\n#jio-block-actions.is-selected .jio-creator__block-action:hover {\n\tborder-color: #cf8574;\n\tbackground: #fbe7e1;\n}\n\n/* 第一次点击选中的块:虚线高亮,明确「还没删」。 */\n.jio-creator__block-selected {\n\toutline: 2px dashed rgba(180, 87, 63, 0.55);\n\toutline-offset: 3px;\n\tborder-radius: 4px;\n}\n\n/*\n * 代码块:与前台文章页保持一致,只用 pre > code。\n * 前台由 EnlighterJS 高亮,编辑器里给出同一份底色与等宽排版。\n */\npre {\n\tmargin: 0 0 1.1em;\n\tpadding: 14px 18px;\n\toverflow-x: auto;\n\tborder-radius: 8px;\n\tbackground: #f2f4f5;\n\tcolor: #2b2b2b;\n\tfont-family: Consolas, Monaco, "Courier New", monospace;\n\tfont-size: 13px;\n\tline-height: 1.6;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n}\npre code {\n\tborder: 0;\n\tbackground: transparent;\n\tcolor: inherit;\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tline-height: inherit;\n\tpadding: 0;\n\twhite-space: inherit;\n}\n\n/* 引用:与前台主题的 .quote_q 视觉一致。 */\n.quote_q {\n\tposition: relative;\n\tmargin: 10px 0 20px;\n\tpadding: 1.2em;\n\tborder-radius: 6px;\n\t--quote-color: #555;\n\tcolor: var(--quote-color);\n}\n.quote_q::before {\n\tposition: absolute;\n\tinset: 0;\n\tborder-radius: 6px;\n\tbackground: var(--quote-color);\n\tcontent: \'\';\n\topacity: 0.04;\n}\n.quote_q.quote-mce::after {\n\tposition: absolute;\n\ttop: 20px;\n\tleft: 20px;\n\twidth: 1em;\n\theight: 1em;\n\tcolor: var(--quote-color);\n\tcontent: \'\';\n\tfont-size: 1.2em;\n\tline-height: 1;\n\topacity: 0.6;\n\t/* 引号用图标字体绘制时依赖 FA;这里用内联 SVG 数据,编辑器与前台都不缺图标。 */\n\tbackground: var(--quote-color);\n\t-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 512 512\'%3E%3Cpath d=\'M464 256h-80v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8c-88.4 0-160 71.6-160 160v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48zm-288 0H96v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8C71.6 32 0 103.6 0 192v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z\'/%3E%3C/svg%3E") center / contain no-repeat;\n\tmask: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 512 512\'%3E%3Cpath d=\'M464 256h-80v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8c-88.4 0-160 71.6-160 160v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48zm-288 0H96v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8C71.6 32 0 103.6 0 192v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z\'/%3E%3C/svg%3E") center / contain no-repeat;\n}\n.quote_q > div {\n\tposition: relative;\n\tmin-height: 24px;\n\tpadding-left: 2em;\n\topacity: 0.7;\n}\n.quote_q > div > :first-child { margin-top: 0; }\n.quote_q > div > :last-child { margin-bottom: 0; }\n.quote_q [contenteditable="true"] {\n\toutline: 0;\n\tborder-radius: 0;\n\tbox-shadow: none;\n}\n.quote_q.qe_wzk_c-red { --quote-color: #dc3f3f; }\n.quote_q.qe_wzk_lan { --quote-color: #0092ff; }\n.quote_q.qe_wzk_lv { --quote-color: #23790e; }\n\n/* 表格。 */\n.jio-content-table {\n\twidth: 100%;\n\tmargin: 0 0 1.1em;\n\tborder-collapse: collapse;\n\tfont-size: 14px;\n}\n.jio-content-table th,\n.jio-content-table td {\n\tpadding: 10px 12px;\n\tborder: 1px solid #e6e9e8;\n\tline-height: 1.6;\n}\n.jio-content-table thead th {\n\tbackground: #f6f8f7;\n\tfont-weight: 600;\n\ttext-align: left;\n}\n.jio-content-table.is-striped tbody tr:nth-child(odd) td { background: #f7f9f8; }\n\n/* 公式:独占一行时居中显示,不铺满整行底色。 */\n.jio-math {\n\tfont-family: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;\n\tfont-size: 1.05em;\n\twhite-space: pre-wrap;\n}\n.jio-math--block {\n\tdisplay: block;\n\tmax-width: 100%;\n\tmargin: 0 auto;\n\tpadding: 2px 0;\n\toverflow-x: auto;\n\ttext-align: center;\n\tbackground: transparent;\n\tborder: 0;\n}\n.jio-math sup, .jio-math sub { font-size: 0.72em; }\n\n/* 隐藏内容:短代码放进 .hide-before / .hide-after,编辑器只显示可读标签。 */\n.tinymce-hide {\n\tposition: relative;\n\tmargin: 18px 0;\n\tpadding: 38px 14px 14px;\n\tborder: 1px dashed rgba(240, 68, 148, 0.35);\n\tborder-radius: 6px;\n\tbackground: rgba(240, 68, 148, 0.04);\n}\n.tinymce-hide > .hide-before,\n.tinymce-hide > .hide-after {\n\tmargin: 0;\n\tfont-family: Consolas, Monaco, monospace;\n\tfont-size: 0;\n\tline-height: 1.5;\n\tcolor: #f04494;\n}\n.tinymce-hide > .hide-before {\n\tposition: absolute;\n\ttop: 10px;\n\tleft: 14px;\n}\n.tinymce-hide > .hide-before::before {\n\tcontent: attr(data-jio-hide-label);\n\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;\n\tfont-size: 12px;\n\tfont-weight: 600;\n\tletter-spacing: 0.02em;\n}\n.tinymce-hide > .hide-after {\n\tdisplay: none;\n}\n.tinymce-hide > [contenteditable="true"] {\n\tmin-height: 38px;\n\tpadding: 10px;\n\tborder-radius: 4px;\n\tbackground: rgba(255, 255, 255, 0.75);\n\toutline: 0;\n}\n.tinymce-hide > [contenteditable="true"] > :first-child { margin-top: 0; }\n.tinymce-hide > [contenteditable="true"] > :last-child { margin-bottom: 0; }\n\n/* 注释:编辑器里显示上标标记,发布后由服务端渲染编号与注释列表。 */\n.jio-footnote-ref {\n\tdisplay: inline-block;\n\tmax-width: 100%;\n\tpadding: 0 6px;\n\tborder-radius: 4px;\n\tbackground: #eef5f2;\n\tcolor: #267665;\n\tfont-size: 0.78em;\n\tline-height: 1.6;\n\tvertical-align: super;\n\tcursor: default;\n}\n.jio-footnote-ref::before {\n\tcontent: \'注 \';\n\topacity: 0.6;\n}\n\n/* 附件链接。 */\n.jio-file-link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tpadding: 6px 12px;\n\tborder: 1px solid #e6e9e8;\n\tborder-radius: 6px;\n\tbackground: #f7f8f8;\n\ttext-decoration: none;\n}\n',height:520,placeholder:String(J.limits?.contentPlaceholder||""),setup:e=>{l.current=e,e.on("init",()=>{d.current=!0,f(!0),null!==s.current?(e.setContent(S(s.current)),s.current=null):e.setContent(S(e.getContent())),O(e),function(e){const t=e.getDoc();if(!t||t.getElementById("jio-block-actions"))return;const a=t.createElement("div");a.id="jio-block-actions",a.className="jio-creator__block-actions",a.setAttribute("data-mce-bogus","all"),a.innerHTML='<button type="button" class="jio-creator__block-action" data-jio-block-delete><span class="jio-creator__block-action-icon" aria-hidden="true">&#10005;</span><span class="jio-creator__block-action-text"></span></button>',t.body.appendChild(a);const n=a.querySelector("[data-jio-block-delete]"),o=a.querySelector(".jio-creator__block-action-text");let r=null,i=null;const l=e=>"selected"===e?"再次点击删除此块":"选中此块",c=e=>{a.classList.toggle("is-selected","selected"===e),o&&(o.textContent=l(e));const t=l(e);n?.setAttribute("title",t),n?.setAttribute("aria-label",t)},s=e=>{const n=e.getBoundingClientRect(),o=Math.max(n.left+8,n.right-96);a.style.top=`${n.top+t.documentElement.scrollTop+6}px`,a.style.left=`${o+t.documentElement.scrollLeft}px`},d=e=>{e&&e!==t.body&&("P"!==e.tagName||""!==(e.textContent||"").trim()||e.querySelector("img,iframe,table,pre"))?(r=e,s(e),a.classList.add("is-visible")):a.classList.remove("is-visible")},m=()=>{i&&i.classList.remove(H),i=null,c("idle"),r?d(r):a.classList.remove("is-visible")};t.addEventListener("mouseover",e=>{const a=e.target?.closest?.("table,pre,hr,.quote_q,.tinymce-hide,p");a&&a!==t.body&&(i||d(a))}),t.addEventListener("mouseleave",()=>{r=null,i?s(i):a.classList.remove("is-visible")}),a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("click",t=>{const n=t.target?.closest("[data-jio-block-delete]"),o=i||r;if(!n||!o)return;if(t.preventDefault(),i!==o)return i&&i.classList.remove(H),i=o,o.classList.add(H),c("selected"),s(o),void a.classList.add("is-visible");const l=o,d=l.parentElement;l.classList.remove(H),i=null,r=null,a.classList.remove("is-visible","is-selected"),c("idle"),e.undoManager.transact(()=>{e.dom.remove(l)}),0===e.getBody().children.length&&e.setContent("<p></p>"),d&&0===d.children.length&&e.setContent("<p></p>");const m=e.getBody().firstChild;m&&e.selection.setCursorLocation(m,0),e.nodeChanged(),e.undoManager.add(),O(e)}),t.addEventListener("mousedown",e=>{a.contains(e.target)||i&&m()}),t.addEventListener("keydown",e=>{"Escape"===e.key&&i&&m()}),e.on("Undo Redo SetContent",()=>{i&&!t.body.contains(i)&&(i=null,c("idle"),a.classList.remove("is-visible","is-selected"))})}(e),me(e),ue(e),pe(e)}),e.on("NodeChange",()=>{ue(e),pe(e)}),e.on("input change Undo Redo AddUndo",()=>{de(C(e.getContent())),me(e),O(e)}),e.on("keydown",t=>{if((t.metaKey||t.ctrlKey)&&83===t.keyCode)return t.preventDefault(),void m.current();!function(e,t){const a=Number(t.keyCode);if(8!==a&&46!==a)return;const n=e.selection;if(!n||!n.isCollapsed())return;const o=e.getBody(),r=n.getNode(),i=(l=r)&&1===l.nodeType&&""===(l.textContent||"").trim()&&!e.dom.getParent(l,F,o)?r:null;var l;const c=i?8===a?i.previousElementSibling:i.nextElementSibling:null;if((e=>!!e&&1===e.nodeType&&!!e.matches?.(F))(c))return t.preventDefault(),e.dom.remove(c),e.nodeChanged(),void e.undoManager.add();const s=e.dom.getParent(r,F,o);if(!s)return;const d=t=>{const a=e.dom.createRng();a.selectNodeContents(s),a.collapse(t);const o=n.getRng();return o&&"function"==typeof o.compareBoundaryPoints&&0===o.compareBoundaryPoints(t?1:3,a)};if(!(8===a&&d(!0)||46===a&&d(!1)))return;t.preventDefault();const m=s.parentElement;e.dom.remove(s),m&&0===m.children.length&&(e.setContent("<p></p>"),e.selection.setCursorLocation(e.getBody().firstChild,0)),e.nodeChanged(),e.undoManager.add()}(e,t)})}}};return e.initialize(Y,t),()=>{e.remove?.(Y),d.current=!1,l.current=null}},[de,pe,ue]);const ve=(0,t.useCallback)(()=>{try{const e=window.localStorage.getItem(X);if(e){const t=JSON.parse(e),a={};"string"==typeof t.title&&(a.title=t.title),"string"==typeof t.content&&(a.content=t.content),se(a),"string"==typeof t.content&&(d.current?l.current?.setContent(t.content):s.current=t.content)}}catch(e){}ae(null)},[se]),Ee=(0,t.useCallback)(()=>{const e=l.current;e&&!e.removed&&(c.current=e.selection.getBookmark(2,!0))},[]),ke=(0,t.useCallback)(()=>{const e=l.current;if(!e||e.removed)return null;if(e.focus(),c.current){try{e.selection.moveToBookmark(c.current)}catch(e){}c.current=null}return e},[]),Ne=(0,t.useCallback)((e,t)=>{const a=ke();if(a){if("undo"===e)a.undoManager.undo();else if("redo"===e)a.undoManager.redo();else if("format"===e){const e=t||"p";a.execCommand("FormatBlock",!1,e),ue(a)}else"align"===e?(a.execCommand("center"===t?"JustifyCenter":"right"===t?"JustifyRight":"JustifyLeft"),pe(a)):a.execCommand(e);a.nodeChanged()}},[ke,pe,ue]),we=(0,t.useCallback)(()=>{const e=ke();if(!e)return;const t=window.wpLink;if(t&&"function"==typeof t.open)return void t.open(e.id);const n=window.prompt((0,a.__)("输入链接地址","jio"),"https://"),o=n?G(n):"";o&&e.execCommand("mceInsertLink",!1,{href:o})},[ke]),Ce=(0,t.useCallback)(e=>{const t=ke();t&&e&&(t.insertContent(e),t.undoManager.add(),t.nodeChanged(),de(C(t.getContent())),me(t),O(t))},[ke]),Se=(0,t.useCallback)(e=>{if(Ee(),"table"!==e&&"math"!==e&&"footnote"!==e)if("code"!==e){if("ul"===e||"ol"===e){const t=ke();return void(t&&(t.execCommand("ol"===e?"InsertOrderedList":"InsertUnorderedList"),t.undoManager.add(),t.nodeChanged(),de(C(t.getContent())),pe(t)))}"divider"===e&&Ce("<hr><p></p>")}else Ce("<pre><code></code></pre><p></p>");else T(e)},[ke,Ce,Ee,pe]),xe=(0,t.useCallback)(e=>{const t=ke();if(!t)return;if(""===String(t.selection.getContent({format:"html"})||"").trim()){const e=t.selection.getNode();e&&"P"===e.nodeName&&e.parentNode===t.getBody()&&t.selection.select(e)}const a=String(t.selection.getContent({format:"html"})||"").trim();t.undoManager.transact(()=>{t.insertContent(e(a))}),t.nodeChanged(),de(C(t.getContent())),me(t),O(t),pe(t)},[ke,pe]),Me=(0,t.useCallback)(e=>{const t=ke();if(!t)return;const a=t.dom.getParent(t.selection.getNode(),".quote_q");if(a){const n=["quote_q","quote-mce"];return e&&n.push(e),a.className=n.join(" "),t.nodeChanged(),pe(t),void de(C(t.getContent()))}xe(t=>function(e,t){const a=["quote_q","quote-mce"];return t&&a.push(t),`<div class="${a.join(" ")}" contenteditable="false"><div contenteditable="true">${U(e)}</div></div><p></p>`}(t,e))},[ke,pe,xe]),Le=(0,t.useCallback)(e=>{const t=ke();if(!t)return;const a=t.dom.getParent(t.selection.getNode(),".tinymce-hide");if(a)return function(e,t){const a=V[t];e.setAttribute("data-jio-hide-type",t);const n=e.querySelector(":scope > .hide-before"),o=e.querySelector(":scope > .hide-after");n&&(n.textContent=a.open,n.setAttribute("data-jio-hide-label",a.label)),o&&(o.textContent=a.close)}(a,e),t.nodeChanged(),void de(C(t.getContent()));xe(t=>function(e,t){const a=V[e];return`<div class="tinymce-hide" data-jio-hide-type="${e}"><p class="hide-before" data-jio-hide-label="${z(a.label)}">${z(a.open)}</p><div contenteditable="true">${U(t)}</div><p class="hide-after">${z(a.close)}</p></div><p></p>`}(e,t))},[ke,xe]),$e=(0,t.useCallback)(e=>{T(null),"table"===e.kind?Ce(function({rows:e,cols:t,header:n,striped:o}){const r=Math.max(1,Math.min(20,e)),i=Math.max(1,Math.min(10,t)),l=e=>Array.from({length:i},(t,n)=>`<${e}>${"th"===e?z(`${(0,a.__)("列","jio")} ${n+1}`):""}</${e}>`).join("");let c="";n&&(c+=`<thead><tr>${l("th")}</tr></thead>`);const s=Math.max(1,n?r-1:r);c+=`<tbody>${Array.from({length:s},()=>`<tr>${l("td")}</tr>`).join("")}</tbody>`;const d=["jio-content-table"];return o&&d.push("is-striped"),`<table class="${d.join(" ")}">${c}</table><p></p>`}(e)):"math"===e.kind?Ce(function({formula:e,display:t}){const a=(n=e.trim(),z(n).replace(/\^\{([^{}]*)\}|\^(\S)/gu,"<sup>$1$2</sup>").replace(/_\{([^{}]*)\}|_(\S)/gu,"<sub>$1$2</sub>"));var n;const o=`data-jio-math-source="${z(e.trim())}" data-jio-math-display="${t?"1":"0"}"`;return t?`<p><span class="jio-math jio-math--block" ${o} contenteditable="false">${a}</span></p>`:`<span class="jio-math" ${o}>${a}</span>`}(e)):Ce(function(e){const t=e.trim()||(0,a.__)("注释内容","jio");return`<sup class="jio-footnote-ref" data-jio-footnote="${z(t)}" contenteditable="false">${z(t)}</sup>`}(e.note))},[Ce]),Pe=(0,t.useCallback)(e=>{const t=l.current,n=window.JioSubmitMedia;t&&n&&"function"==typeof n.open?(Ee(),n.open({type:e,multiple:"image"===e&&void 0,onSelect:t=>{const a=Array.isArray(t)?t:[t],n=ke();if(!n)return;const o=a.map(t=>{const a=G(t?.large_url||t?.url);if(!a)return"";const n=Number(t.attachment_id||t.id||0),o=n>0?` data-edit-file-id="${n}"`:"";if("image"===e){const e=G(t?.url||a),n=e?` data-full-url="${Q(e)}"`:"";return`<p><img src="${Q(a)}"${o} alt="${Q(String(t.name||t.title||""))}"${n}></p>`}if("file"===e){const e=String(t.filename||t.name||a.split("/").pop()||"");return`<p><a class="jio-file-link" href="${Q(a)}"${o}><i class="fa fas fa-paperclip" aria-hidden="true"></i> ${Q(e)}</a></p>`}return`<div contenteditable="false" data-video-url="${Q(a)}" data-video-name="${Q(String(t.filename||t.name||a))}"${o} class="new-dplayer post-dplayer dplayer"></div><p></p>`}).join("");o&&(n.insertContent(o),n.nodeChanged(),de(n.getContent()),me(n))},onEmbed:e=>{const t=ke();t&&(t.insertContent(`${e}<p></p>`),t.nodeChanged(),de(t.getContent()),me(t))}})):ee({tone:"error",text:(0,a.__)("媒体工具尚未加载,请刷新页面后重试。","jio")})},[ke,Ee]);return(0,e.createElement)("div",{className:"jio-creator","data-status":J.status||"","data-editor-ready":_?"true":"false"},(0,e.createElement)("div",{className:"jio-creator__top"},(0,e.createElement)(k,{centerUrl:String(J.urls?.center||""),site:J.site||{},viewer:J.viewer||{}}),(0,e.createElement)("header",{className:"jio-creator__bar"},(0,e.createElement)(h,{ready:_,formatValue:j,onFormatChange:y,alignValue:v,blockValue:x,canUndo:b.canUndo,canRedo:b.canRedo,capabilities:re,onCommand:Ne,onRememberSelection:Ee,onOpenLink:we,onOpenMedia:Pe,onInsertBlock:Se,onInsertQuote:Me,onInsertHidden:Le}))),te&&(0,e.createElement)("div",{className:"jio-creator__notice",role:"status"},(0,e.createElement)("span",null,(0,a.__)("发现本地未同步的草稿。","jio")),(0,e.createElement)("button",{type:"button",onClick:ve},(0,a.__)("恢复","jio")),(0,e.createElement)("button",{type:"button",onClick:()=>ae(null)},(0,a.__)("忽略","jio"))),B&&(0,e.createElement)("div",{className:`jio-creator__notice is-${B.tone}`,role:"status"},(0,e.createElement)("span",null,B.text),(0,e.createElement)("button",{type:"button",onClick:()=>ee(null),"aria-label":(0,a.__)("关闭","jio")},(0,e.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),le&&(0,e.createElement)("p",{className:"jio-creator__hint"},(0,a.__)("这篇改稿不会立即覆盖线上文章;审核通过后才会替换。","jio")),(0,e.createElement)("main",{className:"jio-creator__canvas"},(0,e.createElement)("label",{className:"jio-creator__title"},(0,e.createElement)("span",{className:"screen-reader-text"},(0,a.__)("文章标题","jio")),(0,e.createElement)("textarea",{value:n.title,onChange:e=>se({title:e.target.value}),rows:1,placeholder:(0,a.sprintf)(/* translators: %d: max title length */ /* translators: %d: max title length */
(0,a.__)("请输入标题(最多 %d 个字)","jio"),Number(ie.titleMax)||100),spellCheck:!1,maxLength:Number(ie.titleMax)||100})),(0,e.createElement)("div",{className:"jio-creator__editor","data-editor-ready":_?"true":"false"},(0,e.createElement)("textarea",{id:Y,defaultValue:n.content,onChange:e=>de(e.target.value),"aria-label":(0,a.__)("文章正文","jio")}))),(0,e.createElement)(E,{featured:n.featured,canEditCover:!!re.canUploadImage,canSchedule:!!re.canSchedule,scheduleEnabled:!!n.schedule.enabled,scheduleAt:n.schedule.at,pay:n.pay,canPay:!!re.canPay,taxonomy:{categories:J.categories&&J.categories.items||[],tags:!!J.tags?.enabled,customDefs:J.customDefs||[]},categories:n.categories,tags:n.tags,custom:n.custom,onFeaturedChange:e=>se({featured:e}),onScheduleChange:(e,t)=>se({schedule:{enabled:e,at:t}}),onPayEnabledChange:e=>se({pay:{...i.current.pay,enabled:e}}),onCategoriesChange:e=>se({categories:e}),onTagsChange:e=>se({tags:e}),onCustomChange:e=>se({custom:e}),onOpenPaySettings:()=>q(!0)}),A&&(0,e.createElement)(K,{kind:A,onSubmit:$e,onClose:()=>T(null)}),(0,e.createElement)(D,{charCount:ce,saveState:L,isPublishedEdit:le,saving:!_||"saving"===L.state||"submitting"===L.state,onSaveDraft:()=>{fe(!1)},onPreview:()=>{ge()},onPublish:()=>R(!0)}),P&&(0,e.createElement)(u,{draft:n,setDraft:se,capabilities:re,isPublishedEdit:le,onClose:()=>q(!1),privateStorage:!!J.privateStorage,privateUploads:J.privateUploads||[]}),I&&(0,e.createElement)(p,{canPublishNow:!!re.canPublishNow,isPublishedEdit:le,captcha:!!J.captcha?.enabled,saving:"saving"===L.state||"submitting"===L.state,canSubmit:(n.title||"").trim().length>=Number(ie.titleMin||1),onClose:()=>R(!1),onSaveDraft:()=>{fe(!1)},onSubmit:e=>{be(e)}}))}function te(){const a=document.getElementById("jio-creator-studio");a&&(a.classList.add("is-ready"),(0,t.createRoot)(a).render((0,e.createElement)(ee,null)))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",te):te()})();