From d07cffe99e7f34ef9826da34c3d8a2601351d3a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Nov 2026 15:49:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(creator-studio):=20=E6=B2=89=E6=B5=B8?= =?UTF-8?q?=E5=BC=8F=E5=B8=83=E5=B1=80=E4=B8=8E=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E5=BC=8F=E5=86=99=E4=BD=9C=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首轮实机体验暴露的问题: - 投稿页仍在渲染主题头部的 all_top_fluid 挂件区、页脚与浮动入口, 与工作台顶栏重复。header.php / footer.php 新增 jio_render_header、 jio_render_footer、jio_render_fluid_widgets 过滤器,工作台模式下全部关闭 - 区块 Inspector 被写在 BlockList 之后,作为正文流的一部分渲染出 一个巨大的「未选择区块」白框;移除内联 Inspector(区块设置改由 行内工具栏的区块菜单提供) - 中文正文被 wordcount 的 'words' 口径算成「字数:1」;改用 characters_excluding_spaces,与前台 TinyMCE 字数一致 - 行宽 820px、标题 34px 偏松散;收窄到 720px / 27px,正文 16px/1.85, 段落间距与选区描边收敛,行内工具栏改为深色圆角悬浮条 新增本地视觉验收脚本(不参与运行时): - scripts/preview.cjs:用模拟 bootstrap 生成离线预览页 - scripts/shoot.cjs:桌面/移动端截图与控制台错误采集 Co-Authored-By: Claude Opus 5 (1M context) --- assets/creator-studio/build/index.asset.php | 2 +- assets/creator-studio/build/index.css | 2 +- assets/creator-studio/build/index.js | 2 +- assets/creator-studio/scripts/preview.cjs | 106 +++++++++++++++++++ assets/creator-studio/scripts/shoot.cjs | 75 +++++++++++++ assets/creator-studio/src/index.tsx | 17 +-- assets/creator-studio/src/styles/studio.scss | 89 +++++++++++----- footer.php | 2 + header.php | 6 +- templates/pages/page-submit.php | 10 +- 10 files changed, 272 insertions(+), 39 deletions(-) create mode 100644 assets/creator-studio/scripts/preview.cjs create mode 100644 assets/creator-studio/scripts/shoot.cjs diff --git a/assets/creator-studio/build/index.asset.php b/assets/creator-studio/build/index.asset.php index 4f768bf9..684d7de1 100644 --- a/assets/creator-studio/build/index.asset.php +++ b/assets/creator-studio/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n', 'wp-wordcount'), 'version' => 'd48b7a862f5ed6e6e859'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n', 'wp-wordcount'), 'version' => 'c0ff9955a1748c193f64'); diff --git a/assets/creator-studio/build/index.css b/assets/creator-studio/build/index.css index 94ae7f05..979bd514 100644 --- a/assets/creator-studio/build/index.css +++ b/assets/creator-studio/build/index.css @@ -1 +1 @@ -.jio-page-submit{background:#fafbfa}.jio-page-submit .float-btn,.jio-page-submit .footer,.jio-page-submit .footer-tabbar,.jio-page-submit .header,.jio-page-submit .jio-float-buttons{display:none!important}.jio-page-submit #main-content.container{max-width:none;padding:0}#jio-creator-studio.is-ready{display:block}.jio-creator{--jc-ink:#243330;--jc-ink-soft:#5c6b66;--jc-paper:#fafbfa;--jc-line:#e2e9e5;--jc-accent:#267665;--jc-accent-strong:#1d5f52;--jc-warn:#b4573f;--jc-bar:60px;-webkit-font-smoothing:antialiased;background:var(--jc-paper);color:var(--jc-ink);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans SC,PingFang SC,Microsoft YaHei,sans-serif;min-height:100vh;min-height:100dvh}.jio-creator *,.jio-creator :after,.jio-creator :before{box-sizing:border-box}.jio-creator button{color:inherit;font:inherit}.jio-creator__bar{align-items:center;backdrop-filter:blur(10px);background:rgba(250,251,250,.92);border-bottom:1px solid var(--jc-line);display:flex;gap:16px;height:var(--jc-bar);padding:0 clamp(16px,4vw,40px);position:sticky;top:0;z-index:30}.jio-creator__back{align-items:center;color:var(--jc-ink-soft);display:inline-flex;gap:6px;text-decoration:none}.jio-creator__back:focus-visible,.jio-creator__back:hover{color:var(--jc-accent)}.jio-creator__brand{color:var(--jc-ink-soft);font-size:13px;letter-spacing:.06em;margin-right:auto}.jio-creator__actions{align-items:center;display:flex;gap:10px}.jio-creator__save{align-items:center;color:var(--jc-ink-soft);display:inline-flex;font-size:13px;gap:6px}.jio-creator__save>i{color:var(--jc-line);font-size:7px}.jio-creator__save time{font-variant-numeric:tabular-nums;opacity:.7}.jio-creator__save.is-saved>i{color:var(--jc-accent)}.jio-creator__save.is-conflict,.jio-creator__save.is-conflict>i,.jio-creator__save.is-error,.jio-creator__save.is-error>i{color:var(--jc-warn)}.jio-creator__btn,.jio-creator__ghost,.jio-creator__primary{align-items:center;border:1px solid transparent;border-radius:8px;cursor:pointer;display:inline-flex;font-size:14px;justify-content:center;min-height:36px;padding:0 16px;transition:background .18s ease,border-color .18s ease,color .18s ease}.jio-creator__ghost{background:transparent;border-color:var(--jc-line)}.jio-creator__ghost:focus-visible,.jio-creator__ghost:hover{border-color:var(--jc-accent);color:var(--jc-accent)}.jio-creator__primary{background:var(--jc-accent);color:#fff}.jio-creator__primary:focus-visible,.jio-creator__primary:hover{background:var(--jc-accent-strong)}.jio-creator__primary:disabled{cursor:not-allowed;opacity:.5}.jio-creator__notice{align-items:center;background:#f1f5f2;border-bottom:1px solid var(--jc-line);color:var(--jc-ink-soft);display:flex;font-size:13px;gap:12px;margin:0 auto;max-width:820px;padding:10px 16px}.jio-creator__notice>span{flex:1}.jio-creator__notice button{background:transparent;border:0;color:var(--jc-accent);cursor:pointer}.jio-creator__notice.is-error{background:#fdf2ee;color:var(--jc-warn)}.jio-creator__hint{color:var(--jc-ink-soft);font-size:13px;margin:18px auto 0;max-width:820px;padding:0 clamp(16px,4vw,40px)}.jio-creator__canvas{margin:0 auto;padding:clamp(24px,5vw,56px) clamp(16px,4vw,40px) 120px;width:min(820px,100%)}.jio-creator__title{display:block;margin-bottom:8px}.jio-creator__title textarea{background:transparent;border:0;color:var(--jc-ink);font-family:Songti SC,"Noto Serif SC","Source Han Serif SC",serif;font-size:clamp(26px,3.4vw,34px);font-weight:600;line-height:1.35;min-height:56px;padding:0;resize:none;width:100%}.jio-creator__title textarea:focus{outline:0}.jio-creator__title textarea::-moz-placeholder{color:#b7c2bd}.jio-creator__title textarea::placeholder{color:#b7c2bd}.jio-creator__excerpt{display:block;margin-bottom:28px}.jio-creator__excerpt>span{color:var(--jc-ink-soft);display:block;font-size:12px;margin-bottom:6px}.jio-creator__excerpt textarea{background:transparent;border:0;border-bottom:1px solid var(--jc-line);color:var(--jc-ink-soft);font-family:inherit;font-size:15px;line-height:1.7;padding:8px 0;resize:none;width:100%}.jio-creator__excerpt textarea:focus{border-color:var(--jc-accent);outline:0}.jio-creator__editor{position:relative}.jio-creator__editor .block-editor-writing-flow{font-size:17px;line-height:1.85}.jio-creator__editor .block-editor-default-block-appender textarea.block-editor-default-block-appender__content{color:#b7c2bd}.jio-creator__editor .block-editor-block-list__layout{padding-bottom:80px}.jio-creator__editor .wp-block{max-width:none}.jio-creator__inspector{margin-top:24px}.jio-creator__inspector .block-editor-block-inspector{border-top:1px solid var(--jc-line);padding-top:16px}.jio-creator__inspector .block-editor-block-inspector:empty{display:none}.jio-creator__inspector .components-panel__body{border:0}.jio-creator__footer{border-top:1px solid var(--jc-line);color:var(--jc-ink-soft);display:flex;font-size:12px;justify-content:space-between;padding-top:20px}.jio-creator-drawer{display:flex;inset:0;justify-content:flex-end;position:fixed;z-index:500}.jio-creator-drawer__backdrop{background:rgba(23,34,31,.32);border:0;cursor:default;inset:0;position:absolute}.jio-creator-drawer__panel{background:#fff;box-shadow:-20px 0 60px rgba(20,32,28,.16);display:flex;flex-direction:column;height:100%;position:relative;width:min(460px,100%)}.jio-creator-drawer__head{align-items:center;border-bottom:1px solid #e2e9e5;display:flex;justify-content:space-between;padding:20px 24px}.jio-creator-drawer__head h2{font-size:17px;font-weight:600;margin:0}.jio-creator-drawer__close{background:transparent;border:0;color:#5c6b66;cursor:pointer}.jio-creator-drawer__body{flex:1;overflow-y:auto;padding:20px 24px 32px}.jio-creator-drawer__note{background:#f2f7f4;border-left:3px solid #267665;color:#5c6b66;font-size:13px;line-height:1.6;margin:0 0 20px;padding:12px 14px}.jio-creator-drawer__foot{background:#fff;border-top:1px solid #e2e9e5;display:flex;flex-direction:column;gap:12px;padding:16px 24px calc(16px + env(safe-area-inset-bottom))}.jio-creator-drawer__foot .jio-creator-primary{flex:1}.jio-creator-drawer__actions{align-items:center;display:flex;gap:12px}.jio-creator-drawer__captcha{min-height:40px}.jio-creator-field{margin-bottom:26px}.jio-creator-field>h3{color:#243330;font-size:13px;font-weight:600;margin:0 0 10px}.jio-creator-muted{color:#5c6b66;font-size:12px;line-height:1.6;margin:0}.jio-creator-error{color:#b4573f;font-size:12px;margin:8px 0 0}.jio-creator-chips{display:flex;flex-wrap:wrap;gap:8px}.jio-creator-chip{align-items:center;border:1px solid #e2e9e5;border-radius:999px;color:#5c6b66;cursor:pointer;display:inline-flex;font-size:13px;gap:6px;padding:5px 12px}.jio-creator-chip input{clip:rect(0,0,0,0);height:1px;overflow:hidden;position:absolute;width:1px}.jio-creator-chip.is-active{background:#eef5f2;border-color:#267665;color:#1d5f52}.jio-creator-chip button{background:transparent;border:0;color:inherit;cursor:pointer}.jio-creator-inline{display:flex;gap:8px;margin-top:10px}.jio-creator-inline input:not([type]),.jio-creator-inline input[type=text]{border:1px solid #e2e9e5;border-radius:8px;flex:1;height:36px;min-width:0;padding:0 12px}.jio-creator-inline label{align-items:center;display:inline-flex;font-size:13px;gap:6px}.jio-creator-switch{align-items:flex-start;display:flex;gap:16px;justify-content:space-between}.jio-creator-switch h3{font-size:13px;margin:0 0 4px}.jio-creator-toggle{flex:0 0 auto;position:relative}.jio-creator-toggle input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-toggle span{background:#d6dfda;border-radius:999px;display:block;height:24px;transition:background .18s ease;width:42px}.jio-creator-toggle span:after{background:#fff;border-radius:50%;content:"";display:block;height:18px;margin:3px;transition:transform .18s ease;width:18px}.jio-creator-toggle input:checked+span{background:#267665}.jio-creator-toggle input:checked+span:after{transform:translateX(18px)}.jio-creator-toggle input:focus-visible+span{outline:2px solid #267665;outline-offset:2px}.jio-creator-pay{background:#fcfdfc;border:1px solid #e2e9e5;border-radius:10px;margin-top:16px;padding:16px}.jio-creator-input{align-items:center;display:flex;font-size:13px;gap:12px;justify-content:space-between;margin-top:12px}.jio-creator-input input{border:1px solid #e2e9e5;border-radius:8px;height:36px;padding:0 12px;text-align:right;width:140px}.jio-creator-cover{border-radius:10px;overflow:hidden;position:relative}.jio-creator-cover img{aspect-ratio:2/1;display:block;-o-object-fit:cover;object-fit:cover;width:100%}.jio-creator-cover button{background:rgba(0,0,0,.55);border:0;border-radius:50%;color:#fff;cursor:pointer;height:30px;position:absolute;right:8px;top:8px;width:30px}.jio-creator-cover-empty{align-items:center;background:#fafcfb;border:1px dashed #e2e9e5;border-radius:10px;color:#5c6b66;cursor:pointer;display:flex;flex-direction:column;font-size:13px;gap:8px;justify-content:center;min-height:120px}.jio-creator-cover-empty input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-attachments{border-top:1px solid #e2e9e5;margin-top:18px;padding-top:16px}.jio-creator-attachments__head{align-items:center;display:flex;gap:12px;justify-content:space-between}.jio-creator-attachments__head h4{font-size:13px;margin:0}.jio-creator-upload{align-items:center;border:1px solid #e2e9e5;border-radius:8px;color:#1d5f52;cursor:pointer;display:inline-flex;font-size:12px;min-height:32px;padding:0 12px}.jio-creator-upload input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-files{list-style:none;margin:12px 0 0;padding:0}.jio-creator-files li{align-items:center;border-bottom:1px solid #f0f4f1;display:flex;font-size:13px;gap:10px;padding:8px 0}.jio-creator-files button{background:transparent;border:0;color:#5c6b66;cursor:pointer;margin-left:auto}.jio-creator-files__name{align-items:center;display:inline-flex;gap:8px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jio-creator-files__name i{color:#267665}.jio-creator-reuse{font-size:13px;margin-top:14px}.jio-creator-reuse summary{color:#5c6b66;cursor:pointer}.jio-creator-reuse ul{list-style:none;margin:10px 0 0;padding:0}.jio-creator-reuse li{align-items:center;display:flex;gap:10px;padding:6px 0}.jio-creator-reuse button{background:#fff;border:1px solid #e2e9e5;border-radius:6px;cursor:pointer;margin-left:auto}.jio-creator-link{background:transparent;border:0;color:var(--jc-ink-soft,#5c6b66);cursor:pointer;font-size:13px;text-decoration:underline}@media(max-width:767px){.jio-creator{--jc-bar:54px}.jio-creator__brand{display:none}.jio-creator__bar{gap:10px;padding:0 12px}.jio-creator__save time{display:none}.jio-creator__ghost{padding:0 10px}.jio-creator__primary{padding:0 14px}.jio-creator__canvas{padding:20px 16px calc(120px + env(safe-area-inset-bottom))}.jio-creator__title textarea{font-size:24px}.jio-creator__editor .block-editor-writing-flow{font-size:16px;line-height:1.8}.jio-creator__inspector{margin-top:16px}.jio-creator-drawer{display:block}.jio-creator-drawer__backdrop{display:none}.jio-creator-drawer__panel{border-radius:0;box-shadow:none;height:100dvh;width:100%}.jio-creator-drawer__foot{background:#fff;bottom:0;position:sticky}}@media(prefers-reduced-motion:reduce){.jio-creator *{animation:none!important;transition:none!important}} +.jio-page-submit{background:#fafbfa}.jio-page-submit .float-btn,.jio-page-submit .footer,.jio-page-submit .footer-tabbar,.jio-page-submit .header,.jio-page-submit .jio-float-buttons{display:none!important}.jio-page-submit #main-content.container{max-width:none;padding:0}#jio-creator-studio.is-ready{display:block}.jio-creator{--jc-ink:#243330;--jc-ink-soft:#5c6b66;--jc-paper:#fafbfa;--jc-line:#e2e9e5;--jc-accent:#267665;--jc-accent-strong:#1d5f52;--jc-warn:#b4573f;--jc-bar:60px;-webkit-font-smoothing:antialiased;background:var(--jc-paper);color:var(--jc-ink);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans SC,PingFang SC,Microsoft YaHei,sans-serif;min-height:100vh;min-height:100dvh}.jio-creator *,.jio-creator :after,.jio-creator :before{box-sizing:border-box}.jio-creator button{color:inherit;font:inherit}.jio-creator__bar{align-items:center;backdrop-filter:blur(10px);background:rgba(250,251,250,.92);border-bottom:1px solid var(--jc-line);display:flex;gap:16px;height:var(--jc-bar);padding:0 clamp(16px,4vw,40px);position:sticky;top:0;z-index:30}.jio-creator__back{align-items:center;color:var(--jc-ink-soft);display:inline-flex;gap:6px;text-decoration:none}.jio-creator__back:focus-visible,.jio-creator__back:hover{color:var(--jc-accent)}.jio-creator__brand{color:var(--jc-ink-soft);font-size:13px;letter-spacing:.06em;margin-right:auto}.jio-creator__actions{align-items:center;display:flex;gap:10px}.jio-creator__save{align-items:center;color:var(--jc-ink-soft);display:inline-flex;font-size:13px;gap:6px}.jio-creator__save>i{color:var(--jc-line);font-size:7px}.jio-creator__save time{font-variant-numeric:tabular-nums;opacity:.7}.jio-creator__save.is-saved>i{color:var(--jc-accent)}.jio-creator__save.is-conflict,.jio-creator__save.is-conflict>i,.jio-creator__save.is-error,.jio-creator__save.is-error>i{color:var(--jc-warn)}.jio-creator__btn,.jio-creator__ghost,.jio-creator__primary{align-items:center;border:1px solid transparent;border-radius:8px;cursor:pointer;display:inline-flex;font-size:14px;justify-content:center;min-height:36px;padding:0 16px;transition:background .18s ease,border-color .18s ease,color .18s ease}.jio-creator__ghost{background:transparent;border-color:var(--jc-line)}.jio-creator__ghost:focus-visible,.jio-creator__ghost:hover{border-color:var(--jc-accent);color:var(--jc-accent)}.jio-creator__primary{background:var(--jc-accent);color:#fff}.jio-creator__primary:focus-visible,.jio-creator__primary:hover{background:var(--jc-accent-strong)}.jio-creator__primary:disabled{cursor:not-allowed;opacity:.5}.jio-creator__notice{align-items:center;background:#f1f5f2;border-bottom:1px solid var(--jc-line);color:var(--jc-ink-soft);display:flex;font-size:13px;gap:12px;margin:0 auto;max-width:820px;padding:10px 16px}.jio-creator__notice>span{flex:1}.jio-creator__notice button{background:transparent;border:0;color:var(--jc-accent);cursor:pointer}.jio-creator__notice.is-error{background:#fdf2ee;color:var(--jc-warn)}.jio-creator__hint{color:var(--jc-ink-soft);font-size:13px;margin:18px auto 0;max-width:820px;padding:0 clamp(16px,4vw,40px)}.jio-creator__canvas{margin:0 auto;padding:clamp(20px,4vw,44px) clamp(20px,5vw,52px) 140px;width:min(720px,100%)}.jio-creator__title{display:block;margin-bottom:6px}.jio-creator__title textarea{background:transparent;border:0;color:var(--jc-ink);font-family:Songti SC,"Noto Serif SC","Source Han Serif SC",serif;font-size:clamp(23px,2.6vw,27px);font-weight:500;letter-spacing:.01em;line-height:1.4;min-height:50px;padding:0;resize:none;width:100%}.jio-creator__title textarea:focus{outline:0}.jio-creator__title textarea::-moz-placeholder{color:#b7c2bd}.jio-creator__title textarea::placeholder{color:#b7c2bd}.jio-creator__excerpt{display:block;margin-bottom:22px}.jio-creator__excerpt>span{color:#9aa8a2;display:block;font-size:12px;letter-spacing:.02em;margin-bottom:4px}.jio-creator__excerpt textarea{background:transparent;border:0;color:var(--jc-ink-soft);font-family:inherit;font-size:14px;line-height:1.7;padding:6px 0;resize:none;width:100%}.jio-creator__excerpt textarea:focus{outline:0}.jio-creator__editor{min-height:40vh;position:relative}.jio-creator__editor .block-editor-writing-flow{font-size:16px;letter-spacing:.01em;line-height:1.85}.jio-creator__editor .block-editor-default-block-appender textarea.block-editor-default-block-appender__content{color:#b7c2bd}.jio-creator__editor .block-editor-block-list__layout{padding-bottom:40px}.jio-creator__editor .wp-block{max-width:none}.jio-creator__editor .block-editor-block-list__block{margin-bottom:1.1em;margin-top:0}.jio-creator__editor .block-editor-block-list__block[data-type="core/heading"]{margin-top:1.6em}.jio-creator__editor .block-editor-block-list__block.is-hovered:after,.jio-creator__editor .block-editor-block-list__block.is-selected:after{border-radius:3px;box-shadow:0 0 0 1.5px rgba(38,118,101,.35)}.jio-creator__editor .block-editor-block-contextual-toolbar{margin-left:0}.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar{background:#2b3733;border:0;border-radius:8px;box-shadow:0 6px 20px rgba(20,32,28,.22)}.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-toolbar,.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-toolbar-group{border:0}.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-button{color:hsla(0,0%,100%,.86)}.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-button:focus:not(:disabled),.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-button:hover:not(:disabled){background:hsla(0,0%,100%,.12);color:#fff}.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-button.is-pressed,.jio-creator__editor .block-editor-block-contextual-toolbar .block-editor-block-toolbar .components-button[aria-pressed=true]{background:hsla(0,0%,100%,.2);color:#fff}.jio-creator__footer{border-top:1px solid var(--jc-line);color:var(--jc-ink-soft);display:flex;font-size:12px;justify-content:space-between;padding-top:20px}.jio-creator-drawer{display:flex;inset:0;justify-content:flex-end;position:fixed;z-index:500}.jio-creator-drawer__backdrop{background:rgba(23,34,31,.32);border:0;cursor:default;inset:0;position:absolute}.jio-creator-drawer__panel{background:#fff;box-shadow:-20px 0 60px rgba(20,32,28,.16);display:flex;flex-direction:column;height:100%;position:relative;width:min(460px,100%)}.jio-creator-drawer__head{align-items:center;border-bottom:1px solid #e2e9e5;display:flex;justify-content:space-between;padding:20px 24px}.jio-creator-drawer__head h2{font-size:17px;font-weight:600;margin:0}.jio-creator-drawer__close{background:transparent;border:0;color:#5c6b66;cursor:pointer}.jio-creator-drawer__body{flex:1;overflow-y:auto;padding:20px 24px 32px}.jio-creator-drawer__note{background:#f2f7f4;border-left:3px solid #267665;color:#5c6b66;font-size:13px;line-height:1.6;margin:0 0 20px;padding:12px 14px}.jio-creator-drawer__foot{background:#fff;border-top:1px solid #e2e9e5;display:flex;flex-direction:column;gap:12px;padding:16px 24px calc(16px + env(safe-area-inset-bottom))}.jio-creator-drawer__foot .jio-creator-primary{flex:1}.jio-creator-drawer__actions{align-items:center;display:flex;gap:12px}.jio-creator-drawer__captcha{min-height:40px}.jio-creator-field{margin-bottom:26px}.jio-creator-field>h3{color:#243330;font-size:13px;font-weight:600;margin:0 0 10px}.jio-creator-muted{color:#5c6b66;font-size:12px;line-height:1.6;margin:0}.jio-creator-error{color:#b4573f;font-size:12px;margin:8px 0 0}.jio-creator-chips{display:flex;flex-wrap:wrap;gap:8px}.jio-creator-chip{align-items:center;border:1px solid #e2e9e5;border-radius:999px;color:#5c6b66;cursor:pointer;display:inline-flex;font-size:13px;gap:6px;padding:5px 12px}.jio-creator-chip input{clip:rect(0,0,0,0);height:1px;overflow:hidden;position:absolute;width:1px}.jio-creator-chip.is-active{background:#eef5f2;border-color:#267665;color:#1d5f52}.jio-creator-chip button{background:transparent;border:0;color:inherit;cursor:pointer}.jio-creator-inline{display:flex;gap:8px;margin-top:10px}.jio-creator-inline input:not([type]),.jio-creator-inline input[type=text]{border:1px solid #e2e9e5;border-radius:8px;flex:1;height:36px;min-width:0;padding:0 12px}.jio-creator-inline label{align-items:center;display:inline-flex;font-size:13px;gap:6px}.jio-creator-switch{align-items:flex-start;display:flex;gap:16px;justify-content:space-between}.jio-creator-switch h3{font-size:13px;margin:0 0 4px}.jio-creator-toggle{flex:0 0 auto;position:relative}.jio-creator-toggle input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-toggle span{background:#d6dfda;border-radius:999px;display:block;height:24px;transition:background .18s ease;width:42px}.jio-creator-toggle span:after{background:#fff;border-radius:50%;content:"";display:block;height:18px;margin:3px;transition:transform .18s ease;width:18px}.jio-creator-toggle input:checked+span{background:#267665}.jio-creator-toggle input:checked+span:after{transform:translateX(18px)}.jio-creator-toggle input:focus-visible+span{outline:2px solid #267665;outline-offset:2px}.jio-creator-pay{background:#fcfdfc;border:1px solid #e2e9e5;border-radius:10px;margin-top:16px;padding:16px}.jio-creator-input{align-items:center;display:flex;font-size:13px;gap:12px;justify-content:space-between;margin-top:12px}.jio-creator-input input{border:1px solid #e2e9e5;border-radius:8px;height:36px;padding:0 12px;text-align:right;width:140px}.jio-creator-cover{border-radius:10px;overflow:hidden;position:relative}.jio-creator-cover img{aspect-ratio:2/1;display:block;-o-object-fit:cover;object-fit:cover;width:100%}.jio-creator-cover button{background:rgba(0,0,0,.55);border:0;border-radius:50%;color:#fff;cursor:pointer;height:30px;position:absolute;right:8px;top:8px;width:30px}.jio-creator-cover-empty{align-items:center;background:#fafcfb;border:1px dashed #e2e9e5;border-radius:10px;color:#5c6b66;cursor:pointer;display:flex;flex-direction:column;font-size:13px;gap:8px;justify-content:center;min-height:120px}.jio-creator-cover-empty input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-attachments{border-top:1px solid #e2e9e5;margin-top:18px;padding-top:16px}.jio-creator-attachments__head{align-items:center;display:flex;gap:12px;justify-content:space-between}.jio-creator-attachments__head h4{font-size:13px;margin:0}.jio-creator-upload{align-items:center;border:1px solid #e2e9e5;border-radius:8px;color:#1d5f52;cursor:pointer;display:inline-flex;font-size:12px;min-height:32px;padding:0 12px}.jio-creator-upload input{height:1px;opacity:0;position:absolute;width:1px}.jio-creator-files{list-style:none;margin:12px 0 0;padding:0}.jio-creator-files li{align-items:center;border-bottom:1px solid #f0f4f1;display:flex;font-size:13px;gap:10px;padding:8px 0}.jio-creator-files button{background:transparent;border:0;color:#5c6b66;cursor:pointer;margin-left:auto}.jio-creator-files__name{align-items:center;display:inline-flex;gap:8px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jio-creator-files__name i{color:#267665}.jio-creator-reuse{font-size:13px;margin-top:14px}.jio-creator-reuse summary{color:#5c6b66;cursor:pointer}.jio-creator-reuse ul{list-style:none;margin:10px 0 0;padding:0}.jio-creator-reuse li{align-items:center;display:flex;gap:10px;padding:6px 0}.jio-creator-reuse button{background:#fff;border:1px solid #e2e9e5;border-radius:6px;cursor:pointer;margin-left:auto}.jio-creator-link{background:transparent;border:0;color:var(--jc-ink-soft,#5c6b66);cursor:pointer;font-size:13px;text-decoration:underline}@media(max-width:767px){.jio-creator{--jc-bar:54px}.jio-creator__brand{display:none}.jio-creator__bar{gap:10px;padding:0 12px}.jio-creator__save time{display:none}.jio-creator__ghost{padding:0 10px}.jio-creator__primary{padding:0 14px}.jio-creator__canvas{padding:20px 16px calc(120px + env(safe-area-inset-bottom))}.jio-creator__title textarea{font-size:24px}.jio-creator__editor .block-editor-writing-flow{font-size:16px;line-height:1.8}.jio-creator__inspector{margin-top:16px}.jio-creator-drawer{display:block}.jio-creator-drawer__backdrop{display:none}.jio-creator-drawer__panel{border-radius:0;box-shadow:none;height:100dvh;width:100%}.jio-creator-drawer__foot{background:#fff;bottom:0;position:sticky}}@media(prefers-reduced-motion:reduce){.jio-creator *{animation:none!important;transition:none!important}} diff --git a/assets/creator-studio/build/index.js b/assets/creator-studio/build/index.js index ab753ec6..ae4a8003 100644 --- a/assets/creator-studio/build/index.js +++ b/assets/creator-studio/build/index.js @@ -1 +1 @@ -(()=>{"use strict";const e={n:t=>{const a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.hasOwn(e,t)},t=window.React,a=window.wp.element,r=window.wp.blocks,n=window.wp.blockLibrary,o=window.wp.data,i=window.wp.blockEditor,c=window.wp.wordcount,l=window.wp.i18n;function s(e,t){const a=e&&(e.message||e.error)||(401===t?"登录状态已失效,请刷新页面重新登录。":"请求失败,请稍后重试。"),r=new Error(String(a));return r.status=t,r.code=e&&e.code?String(e.code):"",r.data=e,r}async function m(e){try{return await e.json()}catch(e){return null}}async function u(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)}),n=await m(r);if(!r.ok)throw s(n,r.status);return n}async function d(e,t,a,r={}){const n=new FormData;n.append("file",t),Object.entries(r).forEach(([e,t])=>n.append(e,t));const o=await fetch(e,{method:"POST",credentials:"same-origin",headers:{"X-WP-Nonce":a},body:n}),i=await m(o);if(!o.ok)throw s(i,o.status);return i}const p=window.wp.apiFetch;var _=e.n(p);const f=window.jioCreatorStudio||{},y=f.nonce||"";function b(e){const{draft:r,setDraft:n,capabilities:o,limits:i,taxonomy:c,isPublishedEdit:s,onClose:m,onSaveDraft:u,onSubmit:p,privateStorage:_,privateUploads:b,saving:E,captcha:g}=e,[j,w]=(0,a.useState)(""),[h,v]=(0,a.useState)(""),[N,k]=(0,a.useState)(!1),S=(0,a.useRef)(null),C=(0,a.useRef)(null),I=(0,a.useRef)(null);(0,a.useEffect)(()=>{const e=I.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",""))}},[]);const x=(0,a.useMemo)(()=>(r.title||"").trim().length,[r.title])>=Number(i.titleMin||1),L=()=>{const e=j.trim();if(!e)return;const t=e.split(/[,,\n]+/u).map(e=>e.trim()).filter(Boolean);n({tags:Array.from(new Set([...r.tags,...t]))}),w("")};return(0,t.createElement)("div",{className:"jio-creator-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-publish-title"},(0,t.createElement)("button",{type:"button",className:"jio-creator-drawer__backdrop","aria-label":(0,l.__)("关闭","jio"),onClick:m}),(0,t.createElement)("div",{className:"jio-creator-drawer__panel"},(0,t.createElement)("header",{className:"jio-creator-drawer__head"},(0,t.createElement)("h2",{id:"jio-creator-publish-title"},s?(0,l.__)("提交改稿","jio"):(0,l.__)("发布文章","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator-drawer__close",onClick:m,"aria-label":(0,l.__)("关闭","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,t.createElement)("div",{className:"jio-creator-drawer__body"},s&&(0,t.createElement)("p",{className:"jio-creator-drawer__note"},(0,l.__)("审核通过前,读者看到的仍然是当前线上版本。","jio")),(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("封面","jio")),r.featured?.data?.url?(0,t.createElement)("div",{className:"jio-creator-cover"},(0,t.createElement)("img",{src:String(r.featured.data.url),alt:""}),(0,t.createElement)("button",{type:"button",onClick:()=>n({featured:{type:"",data:{}}}),"aria-label":(0,l.__)("移除封面","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))):o.canUploadImage?(0,t.createElement)("label",{className:"jio-creator-cover-empty"},(0,t.createElement)("input",{ref:S,type:"file",accept:"image/*",onChange:()=>{(async()=>{const e=S.current?.files?.[0];if(e&&f.media?.uploadUrl?.image){v(""),k(!0);try{const t=await d(f.media.uploadUrl.image,e,y),a=Number(t.attachment_id||t.id||0),r=String(t.url||"");if(!a||!r)throw new Error((0,l.__)("上传后无法读取图片。","jio"));n({featured:{type:"image",mediaId:a,data:{id:a,url:r}}})}catch(e){v(String(e?.message||(0,l.__)("上传失败","jio")))}finally{k(!1)}}})()},disabled:N}),(0,t.createElement)("i",{className:"fa fas fa-plus","aria-hidden":"true"}),(0,t.createElement)("span",null,N?(0,l.__)("上传中…","jio"):(0,l.__)("上传封面","jio"))):(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("当前账号不能设置封面。","jio"))),(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("分类","jio")),(0,t.createElement)("div",{className:"jio-creator-chips"},0===c.categories.length&&(0,t.createElement)("span",{className:"jio-creator-muted"},(0,l.__)("暂无可选分类","jio")),c.categories.map(e=>(0,t.createElement)("label",{key:e.id,className:"jio-creator-chip"+(r.categories.includes(e.id)?" is-active":"")},(0,t.createElement)("input",{type:"checkbox",checked:r.categories.includes(e.id),onChange:()=>(e=>{const t=r.categories.includes(e);n({categories:t?r.categories.filter(t=>t!==e):[...r.categories,e]})})(e.id)}),(0,t.createElement)("span",null,e.name))))),c.tags&&(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("标签","jio")),(0,t.createElement)("div",{className:"jio-creator-chips"},r.tags.map(e=>(0,t.createElement)("span",{key:e,className:"jio-creator-chip is-active"},(0,t.createElement)("span",null,e),(0,t.createElement)("button",{type:"button",onClick:()=>n({tags:r.tags.filter(t=>t!==e)}),"aria-label":(0,l.sprintf)((0,l.__)("移除标签 %s","jio"),e)},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))))),(0,t.createElement)("div",{className:"jio-creator-inline"},(0,t.createElement)("input",{type:"text",value:j,placeholder:(0,l.__)("输入标签,逗号分隔","jio"),onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),L())}}),(0,t.createElement)("button",{type:"button",onClick:L},(0,l.__)("添加","jio")))),c.customDefs.map(e=>(0,t.createElement)("section",{className:"jio-creator-field",key:e.key},(0,t.createElement)("h3",null,e.name),(0,t.createElement)("div",{className:"jio-creator-chips"},e.values.map(a=>{const o=r.custom[e.key]||[],i=o.includes(a.key);return(0,t.createElement)("label",{key:a.key,className:"jio-creator-chip"+(i?" is-active":"")},(0,t.createElement)("input",{type:"checkbox",checked:i,onChange:()=>n({custom:{...r.custom,[e.key]:i?o.filter(e=>e!==a.key):[...o,a.key]}})}),(0,t.createElement)("span",null,a.name))})))),o.canPay&&(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("div",{className:"jio-creator-switch"},(0,t.createElement)("div",null,(0,t.createElement)("h3",null,(0,l.__)("付费内容","jio")),(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("开启后,未购买读者只能看到免费部分。","jio"))),(0,t.createElement)("label",{className:"jio-creator-toggle"},(0,t.createElement)("input",{type:"checkbox",checked:r.pay.enabled,onChange:e=>n({pay:{...r.pay,enabled:e.target.checked}})}),(0,t.createElement)("span",{"aria-hidden":"true"}))),r.pay.enabled&&(0,t.createElement)("div",{className:"jio-creator-pay"},(0,t.createElement)("div",{className:"jio-creator-inline"},(0,t.createElement)("label",null,(0,t.createElement)("input",{type:"radio",checked:"cash"===r.pay.modo,onChange:()=>n({pay:{...r.pay,modo:"cash"}})}),(0,t.createElement)("span",null,(0,l.__)("现金","jio"))),(0,t.createElement)("label",null,(0,t.createElement)("input",{type:"radio",checked:"points"===r.pay.modo,onChange:()=>n({pay:{...r.pay,modo:"points"}})}),(0,t.createElement)("span",null,(0,l.__)("积分","jio")))),"cash"===r.pay.modo?(0,t.createElement)("label",{className:"jio-creator-input"},(0,t.createElement)("span",null,(0,l.__)("价格","jio")),(0,t.createElement)("input",{type:"number",min:Number(i.priceMin||0),step:"0.01",value:r.pay.price,onChange:e=>n({pay:{...r.pay,price:e.target.value}})})):(0,t.createElement)("label",{className:"jio-creator-input"},(0,t.createElement)("span",null,(0,l.__)("积分价格","jio")),(0,t.createElement)("input",{type:"number",min:0,step:"1",value:r.pay.points,onChange:e=>n({pay:{...r.pay,points:Number(e.target.value)||0}})})),o.canPayDownload&&(0,t.createElement)("div",{className:"jio-creator-attachments"},(0,t.createElement)("div",{className:"jio-creator-attachments__head"},(0,t.createElement)("h4",null,(0,l.__)("资料附件","jio")),_?(0,t.createElement)("label",{className:"jio-creator-upload"},(0,t.createElement)("input",{ref:C,type:"file",onChange:()=>{(async()=>{const e=C.current?.files?.[0];if(e){v(""),k(!0);try{const t=await d(f.creator.privateUrl,e,y,{post_id:String(r.postId||0)}),a={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:""};n({pay:{...r.pay,enabled:!0,downloads:[...r.pay.downloads,a]}}),C.current&&(C.current.value="")}catch(e){v(String(e?.message||(0,l.__)("资料上传失败","jio")))}finally{k(!1)}}})()},disabled:N}),(0,t.createElement)("span",null,N?(0,l.__)("上传中…","jio"):(0,l.__)("添加 PDF / ZIP","jio"))):(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("私有附件存储尚未配置,暂时不能上传付费资料。","jio"))),h&&(0,t.createElement)("p",{className:"jio-creator-error"},h),r.pay.downloads.length>0&&(0,t.createElement)("ul",{className:"jio-creator-files"},r.pay.downloads.map((e,a)=>(0,t.createElement)("li",{key:`${e.assetKey||e.url}-${a}`},(0,t.createElement)("span",{className:"jio-creator-files__name"},e.assetKey?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("i",{className:"fa fas fa-lock","aria-hidden":"true"}),e.fileName||e.label||(0,l.__)("受保护资料","jio")):(0,t.createElement)(t.Fragment,null,(0,t.createElement)("i",{className:"fa fas fa-link","aria-hidden":"true"}),e.label||e.url)),e.sizeLabel&&(0,t.createElement)("span",{className:"jio-creator-muted"},e.sizeLabel),(0,t.createElement)("button",{type:"button",onClick:()=>(e=>{n({pay:{...r.pay,downloads:r.pay.downloads.filter((t,a)=>a!==e)}})})(a),"aria-label":(0,l.__)("移除","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))))),b.length>0&&(0,t.createElement)("details",{className:"jio-creator-reuse"},(0,t.createElement)("summary",null,(0,l.__)("从已上传资料中选择","jio")),(0,t.createElement)("ul",null,b.filter(e=>!r.pay.downloads.some(t=>t.assetKey===e.assetKey)).map(e=>(0,t.createElement)("li",{key:e.assetKey},(0,t.createElement)("span",null,e.fileName),(0,t.createElement)("span",{className:"jio-creator-muted"},e.sizeLabel),(0,t.createElement)("button",{type:"button",onClick:()=>n({pay:{...r.pay,enabled:!0,downloads:[...r.pay.downloads,{...e,type:"protected"}]}})},(0,l.__)("使用","jio"))))))))),!o.canPay&&o.canSaveDraft&&(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("当前账号不能设置付费内容。","jio"))),(0,t.createElement)("footer",{className:"jio-creator-drawer__foot"},g&&(0,t.createElement)("div",{className:"jio-creator-drawer__captcha",ref:I}),(0,t.createElement)("div",{className:"jio-creator-drawer__actions"},(0,t.createElement)("button",{type:"button",className:"jio-creator-ghost",onClick:u,disabled:E},(0,l.__)("保存草稿","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator-primary",onClick:()=>p(!1),disabled:E||!x},s?(0,l.__)("提交审核","jio"):o.canPublishNow?(0,l.__)("发布","jio"):(0,l.__)("提交审核","jio")),o.canPublishNow&&(0,t.createElement)("button",{type:"button",className:"jio-creator-link",onClick:()=>p(!0),disabled:E||!x},(0,l.__)("立即发布","jio"))))))}const E={ready:(0,l.__)("尚未保存","jio"),saving:(0,l.__)("保存中…","jio"),saved:(0,l.__)("已保存","jio"),error:(0,l.__)("保存失败","jio"),conflict:(0,l.__)("内容已在别处更新","jio"),submitting:(0,l.__)("提交中…","jio"),submitted:(0,l.__)("已提交","jio")};function g({value:e}){return(0,t.createElement)("span",{className:`jio-creator__save is-${e.state}`,role:"status","aria-live":"polite"},(0,t.createElement)("i",{className:"fa fas fa-circle","aria-hidden":"true"}),(0,t.createElement)("span",null,E[e.state]||E.ready),"saved"===e.state&&e.at?(0,t.createElement)("time",null,e.at):null)}function j(e){const t=(e.downloads||[]).map(e=>{const t="string"==typeof e.assetKey?e.assetKey:"";if(t)return{type:"protected",asset_key:t,label:"string"==typeof e.label?e.label:""};const a="string"==typeof e.url?e.url.trim():"";return a?{type:"direct",url:a,label:"string"==typeof e.label?e.label:"",extract_code:"string"==typeof e.extractCode?e.extractCode:""}:null}).filter(Boolean);return{enabled:!!e.enabled,fields:{pay_type:e.enabled?t.length>0?"download":"reading":"no",pay_modo:"points"===e.modo?"points":"0",price:"points"===e.modo?"0.00":String(e.price||"0.00"),points_price:"points"===e.modo?Math.max(0,Number(e.points)||0):0,vip1_price:"points"===e.modo?"0.00":String(e.vip1Price||"0.00"),vip2_price:"points"===e.modo?"0.00":String(e.vip2Price||"0.00"),pay_limit:Number(e.payLimit)||0,downloads:t}}}window.__jioCoreBlocksRegistered||"function"!=typeof n.registerCoreBlocks||((0,n.registerCoreBlocks)(),window.__jioCoreBlocksRegistered=!0);const w=window.jioCreatorStudio||{},h=w.nonce||"",v=`jio-studio-${w.sourceId||0}`;function N(){const e=w.pay||{},t=w.categories&&w.categories.selected||[],a=w.tags&&w.tags.items||[];return{postId:Number(w.sourceId||0),versionId:Number(w.versionId||0),rev:Number(w.versionRev||0),title:String(w.title||""),excerpt:String(w.excerpt||""),content:String(w.content||""),categories:t.map(Number),tags:a.slice(),custom:w.custom||{},featured:w.featured||{type:"",data:{}},pay:{enabled:!!e.enabled,modo:"points"===e.payModo?"points":"cash",price:String(e.price||"0.00"),points:Number(e.points||0),vip1Price:String(e.vip1Price||"0.00"),vip2Price:String(e.vip2Price||"0.00"),payLimit:Number(e.payLimit||0),downloads:Array.isArray(e.downloads)?e.downloads:[]}}}function k(){const[e,n]=(0,a.useState)(N),[s,m]=(0,a.useState)(()=>(0,r.parse)(e.content||"")),[d,p]=(0,a.useState)({state:"ready",at:""}),[_,f]=(0,a.useState)(!1),[y,E]=(0,a.useState)(null),[k,S]=(0,a.useState)(null),C=(0,a.useRef)(!1),I=w.capabilities||{},x={titleMin:Number(w.limits?.titleMin||1),titleMax:Number(w.limits?.titleMax||30),titlePlaceholder:String(w.limits?.titlePlaceholder||(0,l.__)("请输入标题","jio")),priceMin:Number(w.pay?.priceMin||0),priceMax:Number(w.pay?.priceMax||0),pointsMin:Number(w.pay?.pointsMin||0),pointsMax:Number(w.pay?.pointsMax||0)},L=!!w.isPublished,M=(0,a.useCallback)(e=>{C.current=!0,n(t=>({...t,...e}))},[]),P=(0,a.useCallback)(e=>{C.current=!0,m(e)},[]),D=(0,a.useMemo)(()=>(0,r.serialize)(s),[s]),R=(0,a.useMemo)(()=>(0,c.count)(D.replace(/<[^>]*>/g," "),"words",{}),[D]),U=(0,a.useCallback)((t={})=>({post_id:e.postId,version_id:e.versionId,rev:e.rev,title:e.title,excerpt:e.excerpt,content:D,categories:e.categories,tags:e.tags,custom:e.custom,featured:e.featured,pay:j(e.pay),...t}),[e,D]),B=(0,a.useCallback)(async(t=!1)=>{if(!C.current&&(e.postId>0||e.versionId>0))return!0;const a=""!==e.title.trim()||""!==D.replace(/<[^>]*>/g,"").trim();if(t&&!a)return!0;p({state:"saving",at:""});try{const a=await u(w.creator.saveUrl,U({autosave:t}),h),r=Number(a.post_id||e.postId||0),o=Number(a.version_id||e.versionId||0),i=Number(a.rev||a.versionRev||e.rev||0);return C.current=!1,n(e=>({...e,postId:r,versionId:o,rev:i})),p({state:"saved",at:(new Date).toLocaleTimeString()}),!0}catch(e){return p({state:409===e?.status?"conflict":"error",at:""}),!1}},[U,e.postId,e.versionId,e.rev]),F=(0,a.useCallback)(async e=>{if(await B(!1)){p({state:"submitting",at:""});try{let t="";const a=window.JioCaptcha;if(w.captcha?.enabled&&a&&"function"==typeof a.run){const e=await a.run("front_submit");if(null===e)return p({state:"ready",at:""}),void E({tone:"error",text:(0,l.__)("请先完成人机验证","jio")});t=String(e?.jio_captcha_proof||"")}const r=await u(w.creator.submitUrl,U({publish_now:e,captcha_proof:t}),h);C.current=!1,p({state:"submitted",at:""}),E({tone:"ok",text:String(r.message||(0,l.__)("已提交","jio"))}),f(!1);const n=r.url||r.goto||w.urls?.center;n&&window.setTimeout(()=>{window.location.href=n},900)}catch(e){p({state:"error",at:""}),E({tone:"error",text:String(e?.message||(0,l.__)("提交失败","jio"))})}}else E({tone:"error",text:(0,l.__)("内容保存失败,请重试后再提交","jio")})},[U,B]),O=(0,a.useCallback)(async()=>{if(await B(!1))try{const t=await u(w.creator.previewUrl,{post_id:e.postId,version_id:e.versionId},h);t.url&&window.open(String(t.url),"_blank","noopener")}catch(e){E({tone:"error",text:String(e?.message||(0,l.__)("预览失败","jio"))})}},[e.postId,e.versionId,B]),{markLocalSaved:z,clear:T}=function({key:e,snapshot:t,onFound:r}){const n=(0,a.useRef)(t);n.current=t;const o=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!o.current){o.current=!0;try{const a=window.localStorage.getItem(e);if(!a)return;const n=JSON.parse(a),o="string"==typeof n.at?Date.parse(n.at):NaN;if(!Number.isFinite(o)||Date.now()-o>6048e5)return void window.localStorage.removeItem(e);"string"==typeof n.content&&n.content!==t.content&&r(String(n.at))}catch(t){window.localStorage.removeItem(e)}}},[e,r,t.content]),{markLocalSaved:(0,a.useCallback)(()=>{try{window.localStorage.setItem(e,JSON.stringify(n.current))}catch(e){}},[e]),clear:(0,a.useCallback)(()=>{try{window.localStorage.removeItem(e)}catch(e){}},[e])}}({key:v,snapshot:{title:e.title,content:D,at:(new Date).toISOString()},onFound:e=>S({savedAt:e})}),K=function({enabled:e,onSave:t,onLocal:r,remoteDelay:n=4e3,localDelay:o=1500}){const i=(0,a.useRef)(null),c=(0,a.useRef)(null),l=(0,a.useRef)(!1),s=(0,a.useRef)(t),m=(0,a.useRef)(r);s.current=t,m.current=r;const u=(0,a.useCallback)(()=>{i.current&&(window.clearTimeout(i.current),i.current=null),c.current&&(window.clearTimeout(c.current),c.current=null)},[]),d=(0,a.useCallback)(async()=>{if(!l.current){l.current=!0;try{await s.current()}finally{l.current=!1}}},[]),p=(0,a.useCallback)(()=>{u(),m.current(),e&&(c.current=window.setTimeout(()=>m.current(),o),i.current=window.setTimeout(()=>{d()},n))},[u,e,d,o,n]);return(0,a.useEffect)(()=>{if(!e)return;const t=()=>{"hidden"===document.visibilityState&&d()},a=()=>{d()};return document.addEventListener("visibilitychange",t),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("blur",a),u()}},[u,e,d]),(0,a.useMemo)(()=>({schedule:p,flush:d,cancel:u}),[u,d,p])}({enabled:!!I.isLoggedIn,onSave:async()=>{const e=await B(!0);return e&&T(),e},onLocal:z}).schedule;(0,a.useEffect)(()=>{C.current&&K()},[e,D,K]),(0,a.useEffect)(()=>{const e=e=>{C.current&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),(0,a.useEffect)(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()&&(e.preventDefault(),B(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B]);const A=(0,a.useCallback)(()=>{try{const e=window.localStorage.getItem(v);if(e){const t=JSON.parse(e);"string"==typeof t.title&&(C.current=!0,n(e=>({...e,title:t.title}))),"string"==typeof t.content&&(C.current=!0,m((0,r.parse)(t.content)))}}catch(e){}S(null)},[]),J=(0,o.useSelect)(e=>e("core/block-editor").getBlockCount(),[]);return(0,t.createElement)("div",{className:"jio-creator","data-status":w.status||"","data-blocks":J},(0,t.createElement)("header",{className:"jio-creator__bar"},(0,t.createElement)("a",{className:"jio-creator__back",href:w.urls?.center||"/"},(0,t.createElement)("i",{className:"fa fas fa-angle-left","aria-hidden":"true"}),(0,t.createElement)("span",null,(0,l.__)("返回","jio"))),(0,t.createElement)("div",{className:"jio-creator__brand"},"Jio Creator Studio"),(0,t.createElement)("div",{className:"jio-creator__actions"},(0,t.createElement)(g,{value:d}),(0,t.createElement)("button",{type:"button",className:"jio-creator__ghost",onClick:()=>{O()}},(0,l.__)("预览","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator__primary",onClick:()=>f(!0)},L?(0,l.__)("提交改稿","jio"):(0,l.__)("发布","jio")))),k&&(0,t.createElement)("div",{className:"jio-creator__notice",role:"status"},(0,t.createElement)("span",null,(0,l.__)("发现本地未同步的草稿。","jio")),(0,t.createElement)("button",{type:"button",onClick:A},(0,l.__)("恢复","jio")),(0,t.createElement)("button",{type:"button",onClick:()=>S(null)},(0,l.__)("忽略","jio"))),y&&(0,t.createElement)("div",{className:`jio-creator__notice is-${y.tone}`,role:"status"},(0,t.createElement)("span",null,y.text),(0,t.createElement)("button",{type:"button",onClick:()=>E(null),"aria-label":(0,l.__)("关闭","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),L&&(0,t.createElement)("p",{className:"jio-creator__hint"},(0,l.__)("这篇改稿不会立即覆盖线上文章;审核通过后才会替换。","jio")),(0,t.createElement)("main",{className:"jio-creator__canvas"},(0,t.createElement)("label",{className:"jio-creator__title"},(0,t.createElement)("span",{className:"screen-reader-text"},(0,l.__)("文章标题","jio")),(0,t.createElement)("textarea",{value:e.title,onChange:e=>M({title:e.target.value}),rows:1,placeholder:x.titlePlaceholder||(0,l.__)("请输入标题","jio"),maxLength:4*(Number(x.titleMax)||30)})),(0,t.createElement)("label",{className:"jio-creator__excerpt"},(0,t.createElement)("span",null,(0,l.__)("摘要(可选)","jio")),(0,t.createElement)("textarea",{value:e.excerpt,onChange:e=>M({excerpt:e.target.value}),rows:2,placeholder:(0,l.__)("一句话概括这篇文章","jio")})),(0,t.createElement)("div",{className:"jio-creator__editor"},(0,t.createElement)(i.BlockEditorProvider,{value:s,onInput:P,onChange:P,settings:{hasFixedToolbar:!1,supportsLayout:!1,mediaUpload:window.jioCreatorMediaUpload}},(0,t.createElement)(i.BlockTools,null,(0,t.createElement)(i.BlockList,null)),(0,t.createElement)("aside",{className:"jio-creator__inspector","aria-label":(0,l.__)("区块设置","jio")},(0,t.createElement)(i.BlockInspector,null)))),(0,t.createElement)("footer",{className:"jio-creator__footer"},(0,t.createElement)("span",null,(0,l.__)("字数","jio"),":",R),(0,t.createElement)("span",null,(0,l.__)("约","jio")," ",Math.max(1,Math.round(R/400))," ",(0,l.__)("分钟阅读","jio")))),_&&(0,t.createElement)(b,{draft:e,setDraft:M,capabilities:I,limits:x,taxonomy:{categories:w.categories&&w.categories.items||[],tags:!!w.tags?.enabled,customDefs:w.customDefs||[]},isPublishedEdit:L,onClose:()=>f(!1),onSaveDraft:()=>{B(!1)},onSubmit:e=>{F(e)},privateStorage:!!w.privateStorage,privateUploads:w.privateUploads||[],captcha:!!w.captcha?.enabled,saving:"saving"===d.state||"submitting"===d.state}))}function S(){const e=document.getElementById("jio-creator-studio");e&&(function(e){if(!e||"function"!=typeof _().use)return;if(window.__jioApiFetchNonceInstalled)return;window.__jioApiFetchNonceInstalled=!0;const t=_().createNonceMiddleware;"function"!=typeof t?_().use((t,a)=>(t.headers={...t.headers||{},"X-WP-Nonce":e},a(t))):_().use(t(e))}(h),function(e,t){const a=e?.blocks?.mediaUploadUrl;if(!a)return;const r=Number(e?.media?.maxBytes||0),n=!1!==e?.capabilities?.canUploadImage;window.jioCreatorMediaUpload=e=>{const{file:o,onError:i,onSuccess:c}=e||{};if(!o||"object"==typeof o&&!(o instanceof File))return void i?.("无效的文件");if(!n)return void i?.("当前账号不能上传图片");if(r>0&&o.size>r)return void i?.("图片大小超过限制");const l=new FormData;l.append("file",o),fetch(a,{method:"POST",credentials:"same-origin",headers:{"X-WP-Nonce":t},body:l}).then(e=>e.json().then(t=>{if(!e.ok)throw new Error(t&&t.message||"上传失败");return t})).then(e=>{c?.({id:Number(e.attachment_id||e.id||0),url:String(e.url||""),alt:"",caption:"",title:String(e.title||e.name||""),width:Number(e.width||0),height:Number(e.height||0),sizes:e.sizes||{},mime:String(e.mime||"")})}).catch(e=>{i?.(e?.message||"上传失败")})}}(w,h),e.classList.add("is-ready"),(0,a.createRoot)(e).render((0,t.createElement)(k,null)))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",S):S()})(); \ No newline at end of file +(()=>{"use strict";const e={n:t=>{const a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.hasOwn(e,t)},t=window.React,a=window.wp.element,r=window.wp.blocks,n=window.wp.blockLibrary,o=window.wp.data,i=window.wp.blockEditor,c=window.wp.wordcount,l=window.wp.i18n;function s(e,t){const a=e&&(e.message||e.error)||(401===t?"登录状态已失效,请刷新页面重新登录。":"请求失败,请稍后重试。"),r=new Error(String(a));return r.status=t,r.code=e&&e.code?String(e.code):"",r.data=e,r}async function u(e){try{return await e.json()}catch(e){return null}}async function m(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)}),n=await u(r);if(!r.ok)throw s(n,r.status);return n}async function d(e,t,a,r={}){const n=new FormData;n.append("file",t),Object.entries(r).forEach(([e,t])=>n.append(e,t));const o=await fetch(e,{method:"POST",credentials:"same-origin",headers:{"X-WP-Nonce":a},body:n}),i=await u(o);if(!o.ok)throw s(i,o.status);return i}const p=window.wp.apiFetch;var _=e.n(p);const f=window.jioCreatorStudio||{},y=f.nonce||"";function b(e){const{draft:r,setDraft:n,capabilities:o,limits:i,taxonomy:c,isPublishedEdit:s,onClose:u,onSaveDraft:m,onSubmit:p,privateStorage:_,privateUploads:b,saving:E,captcha:g}=e,[j,w]=(0,a.useState)(""),[h,v]=(0,a.useState)(""),[N,k]=(0,a.useState)(!1),S=(0,a.useRef)(null),C=(0,a.useRef)(null),x=(0,a.useRef)(null);(0,a.useEffect)(()=>{const e=x.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",""))}},[]);const I=(0,a.useMemo)(()=>(r.title||"").trim().length,[r.title])>=Number(i.titleMin||1),L=()=>{const e=j.trim();if(!e)return;const t=e.split(/[,,\n]+/u).map(e=>e.trim()).filter(Boolean);n({tags:Array.from(new Set([...r.tags,...t]))}),w("")};return(0,t.createElement)("div",{className:"jio-creator-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"jio-creator-publish-title"},(0,t.createElement)("button",{type:"button",className:"jio-creator-drawer__backdrop","aria-label":(0,l.__)("关闭","jio"),onClick:u}),(0,t.createElement)("div",{className:"jio-creator-drawer__panel"},(0,t.createElement)("header",{className:"jio-creator-drawer__head"},(0,t.createElement)("h2",{id:"jio-creator-publish-title"},s?(0,l.__)("提交改稿","jio"):(0,l.__)("发布文章","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator-drawer__close",onClick:u,"aria-label":(0,l.__)("关闭","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),(0,t.createElement)("div",{className:"jio-creator-drawer__body"},s&&(0,t.createElement)("p",{className:"jio-creator-drawer__note"},(0,l.__)("审核通过前,读者看到的仍然是当前线上版本。","jio")),(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("封面","jio")),r.featured?.data?.url?(0,t.createElement)("div",{className:"jio-creator-cover"},(0,t.createElement)("img",{src:String(r.featured.data.url),alt:""}),(0,t.createElement)("button",{type:"button",onClick:()=>n({featured:{type:"",data:{}}}),"aria-label":(0,l.__)("移除封面","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))):o.canUploadImage?(0,t.createElement)("label",{className:"jio-creator-cover-empty"},(0,t.createElement)("input",{ref:S,type:"file",accept:"image/*",onChange:()=>{(async()=>{const e=S.current?.files?.[0];if(e&&f.media?.uploadUrl?.image){v(""),k(!0);try{const t=await d(f.media.uploadUrl.image,e,y),a=Number(t.attachment_id||t.id||0),r=String(t.url||"");if(!a||!r)throw new Error((0,l.__)("上传后无法读取图片。","jio"));n({featured:{type:"image",mediaId:a,data:{id:a,url:r}}})}catch(e){v(String(e?.message||(0,l.__)("上传失败","jio")))}finally{k(!1)}}})()},disabled:N}),(0,t.createElement)("i",{className:"fa fas fa-plus","aria-hidden":"true"}),(0,t.createElement)("span",null,N?(0,l.__)("上传中…","jio"):(0,l.__)("上传封面","jio"))):(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("当前账号不能设置封面。","jio"))),(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("分类","jio")),(0,t.createElement)("div",{className:"jio-creator-chips"},0===c.categories.length&&(0,t.createElement)("span",{className:"jio-creator-muted"},(0,l.__)("暂无可选分类","jio")),c.categories.map(e=>(0,t.createElement)("label",{key:e.id,className:"jio-creator-chip"+(r.categories.includes(e.id)?" is-active":"")},(0,t.createElement)("input",{type:"checkbox",checked:r.categories.includes(e.id),onChange:()=>(e=>{const t=r.categories.includes(e);n({categories:t?r.categories.filter(t=>t!==e):[...r.categories,e]})})(e.id)}),(0,t.createElement)("span",null,e.name))))),c.tags&&(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("h3",null,(0,l.__)("标签","jio")),(0,t.createElement)("div",{className:"jio-creator-chips"},r.tags.map(e=>(0,t.createElement)("span",{key:e,className:"jio-creator-chip is-active"},(0,t.createElement)("span",null,e),(0,t.createElement)("button",{type:"button",onClick:()=>n({tags:r.tags.filter(t=>t!==e)}),"aria-label":(0,l.sprintf)((0,l.__)("移除标签 %s","jio"),e)},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))))),(0,t.createElement)("div",{className:"jio-creator-inline"},(0,t.createElement)("input",{type:"text",value:j,placeholder:(0,l.__)("输入标签,逗号分隔","jio"),onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),L())}}),(0,t.createElement)("button",{type:"button",onClick:L},(0,l.__)("添加","jio")))),c.customDefs.map(e=>(0,t.createElement)("section",{className:"jio-creator-field",key:e.key},(0,t.createElement)("h3",null,e.name),(0,t.createElement)("div",{className:"jio-creator-chips"},e.values.map(a=>{const o=r.custom[e.key]||[],i=o.includes(a.key);return(0,t.createElement)("label",{key:a.key,className:"jio-creator-chip"+(i?" is-active":"")},(0,t.createElement)("input",{type:"checkbox",checked:i,onChange:()=>n({custom:{...r.custom,[e.key]:i?o.filter(e=>e!==a.key):[...o,a.key]}})}),(0,t.createElement)("span",null,a.name))})))),o.canPay&&(0,t.createElement)("section",{className:"jio-creator-field"},(0,t.createElement)("div",{className:"jio-creator-switch"},(0,t.createElement)("div",null,(0,t.createElement)("h3",null,(0,l.__)("付费内容","jio")),(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("开启后,未购买读者只能看到免费部分。","jio"))),(0,t.createElement)("label",{className:"jio-creator-toggle"},(0,t.createElement)("input",{type:"checkbox",checked:r.pay.enabled,onChange:e=>n({pay:{...r.pay,enabled:e.target.checked}})}),(0,t.createElement)("span",{"aria-hidden":"true"}))),r.pay.enabled&&(0,t.createElement)("div",{className:"jio-creator-pay"},(0,t.createElement)("div",{className:"jio-creator-inline"},(0,t.createElement)("label",null,(0,t.createElement)("input",{type:"radio",checked:"cash"===r.pay.modo,onChange:()=>n({pay:{...r.pay,modo:"cash"}})}),(0,t.createElement)("span",null,(0,l.__)("现金","jio"))),(0,t.createElement)("label",null,(0,t.createElement)("input",{type:"radio",checked:"points"===r.pay.modo,onChange:()=>n({pay:{...r.pay,modo:"points"}})}),(0,t.createElement)("span",null,(0,l.__)("积分","jio")))),"cash"===r.pay.modo?(0,t.createElement)("label",{className:"jio-creator-input"},(0,t.createElement)("span",null,(0,l.__)("价格","jio")),(0,t.createElement)("input",{type:"number",min:Number(i.priceMin||0),step:"0.01",value:r.pay.price,onChange:e=>n({pay:{...r.pay,price:e.target.value}})})):(0,t.createElement)("label",{className:"jio-creator-input"},(0,t.createElement)("span",null,(0,l.__)("积分价格","jio")),(0,t.createElement)("input",{type:"number",min:0,step:"1",value:r.pay.points,onChange:e=>n({pay:{...r.pay,points:Number(e.target.value)||0}})})),o.canPayDownload&&(0,t.createElement)("div",{className:"jio-creator-attachments"},(0,t.createElement)("div",{className:"jio-creator-attachments__head"},(0,t.createElement)("h4",null,(0,l.__)("资料附件","jio")),_?(0,t.createElement)("label",{className:"jio-creator-upload"},(0,t.createElement)("input",{ref:C,type:"file",onChange:()=>{(async()=>{const e=C.current?.files?.[0];if(e){v(""),k(!0);try{const t=await d(f.creator.privateUrl,e,y,{post_id:String(r.postId||0)}),a={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:""};n({pay:{...r.pay,enabled:!0,downloads:[...r.pay.downloads,a]}}),C.current&&(C.current.value="")}catch(e){v(String(e?.message||(0,l.__)("资料上传失败","jio")))}finally{k(!1)}}})()},disabled:N}),(0,t.createElement)("span",null,N?(0,l.__)("上传中…","jio"):(0,l.__)("添加 PDF / ZIP","jio"))):(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("私有附件存储尚未配置,暂时不能上传付费资料。","jio"))),h&&(0,t.createElement)("p",{className:"jio-creator-error"},h),r.pay.downloads.length>0&&(0,t.createElement)("ul",{className:"jio-creator-files"},r.pay.downloads.map((e,a)=>(0,t.createElement)("li",{key:`${e.assetKey||e.url}-${a}`},(0,t.createElement)("span",{className:"jio-creator-files__name"},e.assetKey?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("i",{className:"fa fas fa-lock","aria-hidden":"true"}),e.fileName||e.label||(0,l.__)("受保护资料","jio")):(0,t.createElement)(t.Fragment,null,(0,t.createElement)("i",{className:"fa fas fa-link","aria-hidden":"true"}),e.label||e.url)),e.sizeLabel&&(0,t.createElement)("span",{className:"jio-creator-muted"},e.sizeLabel),(0,t.createElement)("button",{type:"button",onClick:()=>(e=>{n({pay:{...r.pay,downloads:r.pay.downloads.filter((t,a)=>a!==e)}})})(a),"aria-label":(0,l.__)("移除","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))))),b.length>0&&(0,t.createElement)("details",{className:"jio-creator-reuse"},(0,t.createElement)("summary",null,(0,l.__)("从已上传资料中选择","jio")),(0,t.createElement)("ul",null,b.filter(e=>!r.pay.downloads.some(t=>t.assetKey===e.assetKey)).map(e=>(0,t.createElement)("li",{key:e.assetKey},(0,t.createElement)("span",null,e.fileName),(0,t.createElement)("span",{className:"jio-creator-muted"},e.sizeLabel),(0,t.createElement)("button",{type:"button",onClick:()=>n({pay:{...r.pay,enabled:!0,downloads:[...r.pay.downloads,{...e,type:"protected"}]}})},(0,l.__)("使用","jio"))))))))),!o.canPay&&o.canSaveDraft&&(0,t.createElement)("p",{className:"jio-creator-muted"},(0,l.__)("当前账号不能设置付费内容。","jio"))),(0,t.createElement)("footer",{className:"jio-creator-drawer__foot"},g&&(0,t.createElement)("div",{className:"jio-creator-drawer__captcha",ref:x}),(0,t.createElement)("div",{className:"jio-creator-drawer__actions"},(0,t.createElement)("button",{type:"button",className:"jio-creator-ghost",onClick:m,disabled:E},(0,l.__)("保存草稿","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator-primary",onClick:()=>p(!1),disabled:E||!I},s?(0,l.__)("提交审核","jio"):o.canPublishNow?(0,l.__)("发布","jio"):(0,l.__)("提交审核","jio")),o.canPublishNow&&(0,t.createElement)("button",{type:"button",className:"jio-creator-link",onClick:()=>p(!0),disabled:E||!I},(0,l.__)("立即发布","jio"))))))}const E={ready:(0,l.__)("尚未保存","jio"),saving:(0,l.__)("保存中…","jio"),saved:(0,l.__)("已保存","jio"),error:(0,l.__)("保存失败","jio"),conflict:(0,l.__)("内容已在别处更新","jio"),submitting:(0,l.__)("提交中…","jio"),submitted:(0,l.__)("已提交","jio")};function g({value:e}){return(0,t.createElement)("span",{className:`jio-creator__save is-${e.state}`,role:"status","aria-live":"polite"},(0,t.createElement)("i",{className:"fa fas fa-circle","aria-hidden":"true"}),(0,t.createElement)("span",null,E[e.state]||E.ready),"saved"===e.state&&e.at?(0,t.createElement)("time",null,e.at):null)}function j(e){const t=(e.downloads||[]).map(e=>{const t="string"==typeof e.assetKey?e.assetKey:"";if(t)return{type:"protected",asset_key:t,label:"string"==typeof e.label?e.label:""};const a="string"==typeof e.url?e.url.trim():"";return a?{type:"direct",url:a,label:"string"==typeof e.label?e.label:"",extract_code:"string"==typeof e.extractCode?e.extractCode:""}:null}).filter(Boolean);return{enabled:!!e.enabled,fields:{pay_type:e.enabled?t.length>0?"download":"reading":"no",pay_modo:"points"===e.modo?"points":"0",price:"points"===e.modo?"0.00":String(e.price||"0.00"),points_price:"points"===e.modo?Math.max(0,Number(e.points)||0):0,vip1_price:"points"===e.modo?"0.00":String(e.vip1Price||"0.00"),vip2_price:"points"===e.modo?"0.00":String(e.vip2Price||"0.00"),pay_limit:Number(e.payLimit)||0,downloads:t}}}window.__jioCoreBlocksRegistered||"function"!=typeof n.registerCoreBlocks||((0,n.registerCoreBlocks)(),window.__jioCoreBlocksRegistered=!0);const w=window.jioCreatorStudio||{},h=w.nonce||"",v=`jio-studio-${w.sourceId||0}`;function N(){const e=w.pay||{},t=w.categories&&w.categories.selected||[],a=w.tags&&w.tags.items||[];return{postId:Number(w.sourceId||0),versionId:Number(w.versionId||0),rev:Number(w.versionRev||0),title:String(w.title||""),excerpt:String(w.excerpt||""),content:String(w.content||""),categories:t.map(Number),tags:a.slice(),custom:w.custom||{},featured:w.featured||{type:"",data:{}},pay:{enabled:!!e.enabled,modo:"points"===e.payModo?"points":"cash",price:String(e.price||"0.00"),points:Number(e.points||0),vip1Price:String(e.vip1Price||"0.00"),vip2Price:String(e.vip2Price||"0.00"),payLimit:Number(e.payLimit||0),downloads:Array.isArray(e.downloads)?e.downloads:[]}}}function k(){const[e,n]=(0,a.useState)(N),[s,u]=(0,a.useState)(()=>(0,r.parse)(e.content||"")),[d,p]=(0,a.useState)({state:"ready",at:""}),[_,f]=(0,a.useState)(!1),[y,E]=(0,a.useState)(null),[k,S]=(0,a.useState)(null),C=(0,a.useRef)(!1),x=w.capabilities||{},I={titleMin:Number(w.limits?.titleMin||1),titleMax:Number(w.limits?.titleMax||30),titlePlaceholder:String(w.limits?.titlePlaceholder||(0,l.__)("请输入标题","jio")),priceMin:Number(w.pay?.priceMin||0),priceMax:Number(w.pay?.priceMax||0),pointsMin:Number(w.pay?.pointsMin||0),pointsMax:Number(w.pay?.pointsMax||0)},L=!!w.isPublished,M=(0,a.useCallback)(e=>{C.current=!0,n(t=>({...t,...e}))},[]),P=(0,a.useCallback)(e=>{C.current=!0,u(e)},[]),D=(0,a.useMemo)(()=>(0,r.serialize)(s),[s]),R=(0,a.useMemo)(()=>{const e=D.replace(/<[^>]*>/g," ");return(0,c.count)(e,"characters_excluding_spaces",{})},[D]),U=(0,a.useCallback)((t={})=>({post_id:e.postId,version_id:e.versionId,rev:e.rev,title:e.title,excerpt:e.excerpt,content:D,categories:e.categories,tags:e.tags,custom:e.custom,featured:e.featured,pay:j(e.pay),...t}),[e,D]),B=(0,a.useCallback)(async(t=!1)=>{if(!C.current&&(e.postId>0||e.versionId>0))return!0;const a=""!==e.title.trim()||""!==D.replace(/<[^>]*>/g,"").trim();if(t&&!a)return!0;p({state:"saving",at:""});try{const a=await m(w.creator.saveUrl,U({autosave:t}),h),r=Number(a.post_id||e.postId||0),o=Number(a.version_id||e.versionId||0),i=Number(a.rev||a.versionRev||e.rev||0);return C.current=!1,n(e=>({...e,postId:r,versionId:o,rev:i})),p({state:"saved",at:(new Date).toLocaleTimeString()}),!0}catch(e){return p({state:409===e?.status?"conflict":"error",at:""}),!1}},[U,e.postId,e.versionId,e.rev]),F=(0,a.useCallback)(async e=>{if(await B(!1)){p({state:"submitting",at:""});try{let t="";const a=window.JioCaptcha;if(w.captcha?.enabled&&a&&"function"==typeof a.run){const e=await a.run("front_submit");if(null===e)return p({state:"ready",at:""}),void E({tone:"error",text:(0,l.__)("请先完成人机验证","jio")});t=String(e?.jio_captcha_proof||"")}const r=await m(w.creator.submitUrl,U({publish_now:e,captcha_proof:t}),h);C.current=!1,p({state:"submitted",at:""}),E({tone:"ok",text:String(r.message||(0,l.__)("已提交","jio"))}),f(!1);const n=r.url||r.goto||w.urls?.center;n&&window.setTimeout(()=>{window.location.href=n},900)}catch(e){p({state:"error",at:""}),E({tone:"error",text:String(e?.message||(0,l.__)("提交失败","jio"))})}}else E({tone:"error",text:(0,l.__)("内容保存失败,请重试后再提交","jio")})},[U,B]),O=(0,a.useCallback)(async()=>{if(await B(!1))try{const t=await m(w.creator.previewUrl,{post_id:e.postId,version_id:e.versionId},h);t.url&&window.open(String(t.url),"_blank","noopener")}catch(e){E({tone:"error",text:String(e?.message||(0,l.__)("预览失败","jio"))})}},[e.postId,e.versionId,B]),{markLocalSaved:z,clear:T}=function({key:e,snapshot:t,onFound:r}){const n=(0,a.useRef)(t);n.current=t;const o=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!o.current){o.current=!0;try{const a=window.localStorage.getItem(e);if(!a)return;const n=JSON.parse(a),o="string"==typeof n.at?Date.parse(n.at):NaN;if(!Number.isFinite(o)||Date.now()-o>6048e5)return void window.localStorage.removeItem(e);"string"==typeof n.content&&n.content!==t.content&&r(String(n.at))}catch(t){window.localStorage.removeItem(e)}}},[e,r,t.content]),{markLocalSaved:(0,a.useCallback)(()=>{try{window.localStorage.setItem(e,JSON.stringify(n.current))}catch(e){}},[e]),clear:(0,a.useCallback)(()=>{try{window.localStorage.removeItem(e)}catch(e){}},[e])}}({key:v,snapshot:{title:e.title,content:D,at:(new Date).toISOString()},onFound:e=>S({savedAt:e})}),K=function({enabled:e,onSave:t,onLocal:r,remoteDelay:n=4e3,localDelay:o=1500}){const i=(0,a.useRef)(null),c=(0,a.useRef)(null),l=(0,a.useRef)(!1),s=(0,a.useRef)(t),u=(0,a.useRef)(r);s.current=t,u.current=r;const m=(0,a.useCallback)(()=>{i.current&&(window.clearTimeout(i.current),i.current=null),c.current&&(window.clearTimeout(c.current),c.current=null)},[]),d=(0,a.useCallback)(async()=>{if(!l.current){l.current=!0;try{await s.current()}finally{l.current=!1}}},[]),p=(0,a.useCallback)(()=>{m(),u.current(),e&&(c.current=window.setTimeout(()=>u.current(),o),i.current=window.setTimeout(()=>{d()},n))},[m,e,d,o,n]);return(0,a.useEffect)(()=>{if(!e)return;const t=()=>{"hidden"===document.visibilityState&&d()},a=()=>{d()};return document.addEventListener("visibilitychange",t),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("blur",a),m()}},[m,e,d]),(0,a.useMemo)(()=>({schedule:p,flush:d,cancel:m}),[m,d,p])}({enabled:!!x.isLoggedIn,onSave:async()=>{const e=await B(!0);return e&&T(),e},onLocal:z}).schedule;(0,a.useEffect)(()=>{C.current&&K()},[e,D,K]),(0,a.useEffect)(()=>{const e=e=>{C.current&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),(0,a.useEffect)(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()&&(e.preventDefault(),B(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B]);const A=(0,a.useCallback)(()=>{try{const e=window.localStorage.getItem(v);if(e){const t=JSON.parse(e);"string"==typeof t.title&&(C.current=!0,n(e=>({...e,title:t.title}))),"string"==typeof t.content&&(C.current=!0,u((0,r.parse)(t.content)))}}catch(e){}S(null)},[]),J=(0,o.useSelect)(e=>e("core/block-editor").getBlockCount(),[]);return(0,t.createElement)("div",{className:"jio-creator","data-status":w.status||"","data-blocks":J},(0,t.createElement)("header",{className:"jio-creator__bar"},(0,t.createElement)("a",{className:"jio-creator__back",href:w.urls?.center||"/"},(0,t.createElement)("i",{className:"fa fas fa-angle-left","aria-hidden":"true"}),(0,t.createElement)("span",null,(0,l.__)("返回","jio"))),(0,t.createElement)("div",{className:"jio-creator__brand"},"Jio Creator Studio"),(0,t.createElement)("div",{className:"jio-creator__actions"},(0,t.createElement)(g,{value:d}),(0,t.createElement)("button",{type:"button",className:"jio-creator__ghost",onClick:()=>{O()}},(0,l.__)("预览","jio")),(0,t.createElement)("button",{type:"button",className:"jio-creator__primary",onClick:()=>f(!0)},L?(0,l.__)("提交改稿","jio"):(0,l.__)("发布","jio")))),k&&(0,t.createElement)("div",{className:"jio-creator__notice",role:"status"},(0,t.createElement)("span",null,(0,l.__)("发现本地未同步的草稿。","jio")),(0,t.createElement)("button",{type:"button",onClick:A},(0,l.__)("恢复","jio")),(0,t.createElement)("button",{type:"button",onClick:()=>S(null)},(0,l.__)("忽略","jio"))),y&&(0,t.createElement)("div",{className:`jio-creator__notice is-${y.tone}`,role:"status"},(0,t.createElement)("span",null,y.text),(0,t.createElement)("button",{type:"button",onClick:()=>E(null),"aria-label":(0,l.__)("关闭","jio")},(0,t.createElement)("i",{className:"fa fas fa-times","aria-hidden":"true"}))),L&&(0,t.createElement)("p",{className:"jio-creator__hint"},(0,l.__)("这篇改稿不会立即覆盖线上文章;审核通过后才会替换。","jio")),(0,t.createElement)("main",{className:"jio-creator__canvas"},(0,t.createElement)("label",{className:"jio-creator__title"},(0,t.createElement)("span",{className:"screen-reader-text"},(0,l.__)("文章标题","jio")),(0,t.createElement)("textarea",{value:e.title,onChange:e=>M({title:e.target.value}),rows:1,placeholder:I.titlePlaceholder||(0,l.__)("请输入标题","jio"),maxLength:4*(Number(I.titleMax)||30)})),(0,t.createElement)("label",{className:"jio-creator__excerpt"},(0,t.createElement)("span",null,(0,l.__)("摘要(可选)","jio")),(0,t.createElement)("textarea",{value:e.excerpt,onChange:e=>M({excerpt:e.target.value}),rows:2,placeholder:(0,l.__)("一句话概括这篇文章","jio")})),(0,t.createElement)("div",{className:"jio-creator__editor"},(0,t.createElement)(i.BlockEditorProvider,{value:s,onInput:P,onChange:P,settings:{hasFixedToolbar:!1,supportsLayout:!1,mediaUpload:window.jioCreatorMediaUpload}},(0,t.createElement)(i.BlockTools,null,(0,t.createElement)(i.BlockList,null)))),(0,t.createElement)("footer",{className:"jio-creator__footer"},(0,t.createElement)("span",null,(0,l.__)("字数","jio"),":",R),(0,t.createElement)("span",null,(0,l.__)("约","jio")," ",Math.max(1,Math.round(R/400))," ",(0,l.__)("分钟阅读","jio")))),_&&(0,t.createElement)(b,{draft:e,setDraft:M,capabilities:x,limits:I,taxonomy:{categories:w.categories&&w.categories.items||[],tags:!!w.tags?.enabled,customDefs:w.customDefs||[]},isPublishedEdit:L,onClose:()=>f(!1),onSaveDraft:()=>{B(!1)},onSubmit:e=>{F(e)},privateStorage:!!w.privateStorage,privateUploads:w.privateUploads||[],captcha:!!w.captcha?.enabled,saving:"saving"===d.state||"submitting"===d.state}))}function S(){const e=document.getElementById("jio-creator-studio");e&&(function(e){if(!e||"function"!=typeof _().use)return;if(window.__jioApiFetchNonceInstalled)return;window.__jioApiFetchNonceInstalled=!0;const t=_().createNonceMiddleware;"function"!=typeof t?_().use((t,a)=>(t.headers={...t.headers||{},"X-WP-Nonce":e},a(t))):_().use(t(e))}(h),function(e,t){const a=e?.blocks?.mediaUploadUrl;if(!a)return;const r=Number(e?.media?.maxBytes||0),n=!1!==e?.capabilities?.canUploadImage;window.jioCreatorMediaUpload=e=>{const{file:o,onError:i,onSuccess:c}=e||{};if(!o||"object"==typeof o&&!(o instanceof File))return void i?.("无效的文件");if(!n)return void i?.("当前账号不能上传图片");if(r>0&&o.size>r)return void i?.("图片大小超过限制");const l=new FormData;l.append("file",o),fetch(a,{method:"POST",credentials:"same-origin",headers:{"X-WP-Nonce":t},body:l}).then(e=>e.json().then(t=>{if(!e.ok)throw new Error(t&&t.message||"上传失败");return t})).then(e=>{c?.({id:Number(e.attachment_id||e.id||0),url:String(e.url||""),alt:"",caption:"",title:String(e.title||e.name||""),width:Number(e.width||0),height:Number(e.height||0),sizes:e.sizes||{},mime:String(e.mime||"")})}).catch(e=>{i?.(e?.message||"上传失败")})}}(w,h),e.classList.add("is-ready"),(0,a.createRoot)(e).render((0,t.createElement)(k,null)))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",S):S()})(); \ No newline at end of file diff --git a/assets/creator-studio/scripts/preview.cjs b/assets/creator-studio/scripts/preview.cjs new file mode 100644 index 00000000..0b176a9a --- /dev/null +++ b/assets/creator-studio/scripts/preview.cjs @@ -0,0 +1,106 @@ +/** + * 本地视觉预览页:加载 WordPress 官方 dist 脚本 + Creator Studio 构建产物, + * 用一份模拟的 bootstrap 数据渲染工作台,便于在不登录的情况下截图核对视觉。 + * 仅用于本机视觉验收,不进入主题运行时。 + */ +const fs = require('fs'); +const path = require('path'); + +const [srcArg, outArg] = process.argv.slice(2); +const src = srcArg || '/tmp/studio-preview.html'; +const out = outArg || 'C:/Users/Xing/Desktop/WP-Date/data/wordpress/jio-preview.html'; + +let html = fs.readFileSync(src, 'utf8'); + +const mockBootstrap = { + sourceId: 0, + versionId: 0, + versionRev: 0, + status: '', + reviewNote: '', + title: '', + excerpt: '', + content: + '

这是正文的第一段。微信公众号式的编辑体验强调沉浸感:大面积留白、克制的工具栏、只在需要时才出现的设置面板。

', + permalink: '', + isPublished: false, + categories: { + items: [ + { id: 1, name: '未分类' }, + { id: 4, name: '分类一' }, + { id: 5, name: '分类二' }, + ], + selected: [1], + }, + tags: { items: ['写作', '产品'], enabled: true }, + custom: {}, + customDefs: [], + featured: { type: '', data: {}, canImage: true, canSlide: false, canVideo: false }, + pay: { + enabled: false, + canPay: true, + canDownload: true, + payModo: 'cash', + price: '0.00', + points: 0, + vip1Price: '0.00', + vip2Price: '0.00', + payLimit: 0, + downloads: [], + freeAllowed: true, + priceMin: 0, + priceMax: 0, + pointsMin: 0, + pointsMax: 0, + privateStorage: false, + }, + capabilities: { + canUploadImage: true, + canUploadVideo: true, + canUploadFile: true, + canEmbed: true, + canHide: true, + canPay: true, + canPayDownload: true, + canPublishNow: true, + canEdit: true, + isLoggedIn: true, + }, + limits: { titleMin: 5, titleMax: 30, titlePlaceholder: '请输入标题', contentPlaceholder: '开始写作…' }, + privateUploads: [], + privateStorage: false, + media: { maxBytes: 5242880, batch: 6 }, + rest: { root: 'https://localhost/wp-json/', nonce: 'preview' }, + urls: { submit: '#', newPost: '#', center: '#' }, + captcha: { enabled: false }, + creator: { + saveUrl: '#', + submitUrl: '#', + previewUrl: '#', + privateUrl: '#', + bootstrapUrl: '#', + }, + blocks: { mediaUploadUrl: '#', mediaListUrl: '#' }, + nonce: 'preview', +}; + +// 换成模拟数据。WP 的 wp_add_inline_script 会在结尾追加 sourceURL 注释, +// 所以只匹配到 JSON 的结束分号,保留其后的注释。 +const before = html.length; +html = html.replace( + /window\.jioCreatorStudio = \{[\s\S]*?\};\n/, + `window.jioCreatorStudio = ${JSON.stringify(mockBootstrap)};\n` +); +if (html.length === before) { + console.error('WARN: bootstrap 替换未生效'); +} + +// 追加一个 banner 说明这是预览 +html = html.replace( + '', + `
视觉预览(模拟数据)· 非真实登录会话
` +); + +fs.writeFileSync(out, html, 'utf8'); +console.log('written ' + out + ' bytes=' + html.length); +console.log('has studio script: ' + /jio-creator-studio-js/.test(html)); diff --git a/assets/creator-studio/scripts/shoot.cjs b/assets/creator-studio/scripts/shoot.cjs new file mode 100644 index 00000000..a5d5f0eb --- /dev/null +++ b/assets/creator-studio/scripts/shoot.cjs @@ -0,0 +1,75 @@ +/** + * 截图:打开预览页并保存桌面 / 移动端截图,同时把配色、字体与布局尺寸打印出来。 + */ +const fs = require('fs'); +const puppeteer = require('puppeteer-core'); + +const CANDIDATES = [ + process.env.JIO_BROWSER, + 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', + 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', + 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe', + 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe', +].filter(Boolean); +const BROWSER = CANDIDATES.find((p) => fs.existsSync(p)); + +const URL = process.argv[2] || 'https://localhost/jio-preview.html'; +const PREFIX = process.argv[3] || 'C:/Users/Xing/Desktop/WP-Date/data/wordpress/shot'; + +(async () => { + if (!BROWSER) { + console.error('no browser'); + process.exit(1); + } + const browser = await puppeteer.launch({ + executablePath: BROWSER, + headless: 'new', + ignoreHTTPSErrors: true, + args: ['--disable-gpu', '--no-sandbox'], + }); + + for (const [name, viewport] of [ + ['desktop', { width: 1440, height: 1000 }], + ['mobile', { width: 390, height: 844, isMobile: true, hasTouch: true }], + ]) { + const page = await browser.newPage(); + await page.setViewport(viewport); + await page.goto(URL, { waitUntil: 'networkidle2', timeout: 60000 }); + await new Promise((r) => setTimeout(r, 2000)); + await page.screenshot({ path: `${PREFIX}-${name}.png` }); + + const metrics = await page.evaluate(() => { + const pick = (sel) => { + const el = document.querySelector(sel); + if (!el) return null; + const cs = getComputedStyle(el); + const r = el.getBoundingClientRect(); + return { + text: (el.textContent || '').trim().slice(0, 40), + font: `${cs.fontSize}/${cs.lineHeight} ${cs.fontFamily.split(',')[0]}`, + weight: cs.fontWeight, + color: cs.color, + bg: cs.backgroundColor, + pad: cs.padding, + box: `${Math.round(r.width)}x${Math.round(r.height)}`, + }; + }; + return { + bar: pick('.jio-creator__bar'), + title: pick('.jio-creator__title textarea'), + excerpt: pick('.jio-creator__excerpt textarea'), + canvas: pick('.jio-creator__canvas'), + para: pick('.block-editor-block-list__block'), + appender: pick('.block-editor-default-block-appender'), + primaryBtn: pick('.jio-creator__primary'), + ghostBtn: pick('.jio-creator__ghost'), + pageBg: getComputedStyle(document.body).backgroundColor, + }; + }); + console.log(`=== ${name} ===`); + console.log(JSON.stringify(metrics, null, 2)); + await page.close(); + } + + await browser.close(); +})(); diff --git a/assets/creator-studio/src/index.tsx b/assets/creator-studio/src/index.tsx index 4a1af654..91c527c5 100644 --- a/assets/creator-studio/src/index.tsx +++ b/assets/creator-studio/src/index.tsx @@ -12,7 +12,7 @@ import { createRoot, useCallback, useEffect, useMemo, useRef, useState } from '@ import { parse, serialize } from '@wordpress/blocks'; import { registerCoreBlocks } from '@wordpress/block-library'; import { useSelect } from '@wordpress/data'; -import { BlockEditorProvider, BlockList, BlockTools, BlockInspector } from '@wordpress/block-editor'; +import { BlockEditorProvider, BlockList, BlockTools } from '@wordpress/block-editor'; import { count as countWords } from '@wordpress/wordcount'; import { __ } from '@wordpress/i18n'; @@ -133,7 +133,13 @@ function Studio(): JSX.Element { }, []); const serialized = useMemo(() => serialize(blocks), [blocks]); - const words = useMemo(() => countWords(serialized.replace(/<[^>]*>/g, ' '), 'words', {}), [serialized]); + + // 中文没有空格分词,wordcount 的 'words' 会把整段算成 1。 + // 'characters_excluding_spaces' 才是中文场景该用的口径(与前台 TinyMCE 字数一致)。 + const charCount = useMemo(() => { + const text = serialized.replace(/<[^>]*>/g, ' '); + return countWords(text, 'characters_excluding_spaces', {}); + }, [serialized]); const buildPayload = useCallback( (extra: Record = {}) => ({ @@ -400,16 +406,13 @@ function Studio(): JSX.Element { -
- {__('字数', 'jio')}:{words} + {__('字数', 'jio')}:{charCount} - {__('约', 'jio')} {Math.max(1, Math.round(words / 400))} {__('分钟阅读', 'jio')} + {__('约', 'jio')} {Math.max(1, Math.round(charCount / 400))} {__('分钟阅读', 'jio')}
diff --git a/assets/creator-studio/src/styles/studio.scss b/assets/creator-studio/src/styles/studio.scss index 473bbfaf..8a853161 100644 --- a/assets/creator-studio/src/styles/studio.scss +++ b/assets/creator-studio/src/styles/studio.scss @@ -218,26 +218,28 @@ $warn: #b4573f; } .jio-creator__canvas { - width: min(820px, 100%); + /* 公众号式阅读宽度:正文行宽控制在约 40 个汉字,留白优先。 */ + width: min(720px, 100%); margin: 0 auto; - padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px) 120px; + padding: clamp(20px, 4vw, 44px) clamp(20px, 5vw, 52px) 140px; } .jio-creator__title { display: block; - margin-bottom: 8px; + margin-bottom: 6px; textarea { width: 100%; - min-height: 56px; + min-height: 50px; padding: 0; border: 0; background: transparent; color: var(--jc-ink); font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif; - font-size: clamp(26px, 3.4vw, 34px); - font-weight: 600; - line-height: 1.35; + font-size: clamp(23px, 2.6vw, 27px); + font-weight: 500; + letter-spacing: 0.01em; + line-height: 1.4; resize: none; &:focus { @@ -252,29 +254,28 @@ $warn: #b4573f; .jio-creator__excerpt { display: block; - margin-bottom: 28px; + margin-bottom: 22px; > span { display: block; - margin-bottom: 6px; - color: var(--jc-ink-soft); + margin-bottom: 4px; + color: #9aa8a2; font-size: 12px; + letter-spacing: 0.02em; } textarea { width: 100%; - padding: 8px 0; + padding: 6px 0; border: 0; - border-bottom: 1px solid var(--jc-line); background: transparent; color: var(--jc-ink-soft); font-family: inherit; - font-size: 15px; + font-size: 14px; line-height: 1.7; resize: none; &:focus { - border-color: var(--jc-accent); outline: 0; } } @@ -282,10 +283,13 @@ $warn: #b4573f; .jio-creator__editor { position: relative; + /* 行内浮动工具栏相对书写区定位,而不是相对整个页面。 */ + min-height: 40vh; .block-editor-writing-flow { - font-size: 17px; + font-size: 16px; line-height: 1.85; + letter-spacing: 0.01em; } .block-editor-default-block-appender textarea.block-editor-default-block-appender__content { @@ -293,28 +297,61 @@ $warn: #b4573f; } .block-editor-block-list__layout { - padding-bottom: 80px; + padding-bottom: 40px; } .wp-block { max-width: none; } -} -.jio-creator__inspector { - margin-top: 24px; - - .block-editor-block-inspector { - border-top: 1px solid var(--jc-line); - padding-top: 16px; + /* 段落之间留出公众号式的呼吸感,标题上方多留一档。 */ + .block-editor-block-list__block { + margin-top: 0; + margin-bottom: 1.1em; } - .block-editor-block-inspector:empty { - display: none; + .block-editor-block-list__block[data-type='core/heading'] { + margin-top: 1.6em; } - .components-panel__body { + /* 选中时的虚线框收敛成低对比描边,贴近公众号的“轻选中”。 */ + .block-editor-block-list__block.is-selected::after, + .block-editor-block-list__block.is-hovered::after { + box-shadow: 0 0 0 1.5px rgba(38, 118, 101, 0.35); + border-radius: 3px; + } + + /* 行内工具栏:圆角悬浮条,深色底更接近公众号的选中工具条。 */ + .block-editor-block-contextual-toolbar { + margin-left: 0; + } + + .block-editor-block-contextual-toolbar .block-editor-block-toolbar { border: 0; + border-radius: 8px; + background: #2b3733; + box-shadow: 0 6px 20px rgba(20, 32, 28, 0.22); + + .components-toolbar-group, + .components-toolbar { + border: 0; + } + + .components-button { + color: rgba(255, 255, 255, 0.86); + + &:hover:not(:disabled), + &:focus:not(:disabled) { + background: rgba(255, 255, 255, 0.12); + color: #fff; + } + + &.is-pressed, + &[aria-pressed='true'] { + background: rgba(255, 255, 255, 0.2); + color: #fff; + } + } } } diff --git a/footer.php b/footer.php index 2b4d7417..9a0afbe9 100644 --- a/footer.php +++ b/footer.php @@ -63,6 +63,7 @@ $_footer_conter = wp_kses_post(trim((string) $footer_customize_code)); +