Commit Graph
28 Commits
Author SHA1 Message Date
kate522andClaude Opus 5 4f9347b6aa fix(submit): let the editor iframe grow with the body instead of scrolling internally
正文超过 iframe 高度时会在编辑器内部出现第二根滚动条,正文应该随页面一起变长。
登录态实测确认了滚动来源与两个副作用:

1. 经典投稿表单完全没做高度同步(iframe 固定 504px,正文 1824px → 内滚动)。
   在共用基础插件里补上 syncHeight():测量正文高度并同步 iframe,
   下限取编辑器声明高度;图片加载后重新同步。工作台自带 syncEditorHeight()
   负责块浮层定位,用 __jioStudioOwnsEditorHeight 让插件跳过,避免双写。

2. 直接量 scrollHeight 会把 body 的 min-height 撑满算进内容高度,形成
   「撑高 → 再撑高」的反馈循环(实测涨到 22616px)。测量时临时把
   min-height 归零、同帧恢复。

3. body 的 min-height 基准从 100% 改成 100vh:iframe 随正文变高,
   百分比会跟着循环;同时把 WordPress content CSS 的 body 外边距改内边距,
   外边距不计入高度,会让 html 比 iframe 高一截、长正文时又冒出内滚动。

登录态实测(studio 与经典两条路径):
- iframe 2152px / 1874px,与正文一致,innerHasScrollbar=false;
- 空正文占位符正常、点击空白落光标正常;
- 只有页面级滚动。

测试:新增 iframe 随正文增长、测量忽略 min-height 两个回归用例;903 全通过。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 21:37:14 +08:00
kate522andClaude Opus 5 305896796c fix(submit): detect empty body without editor chrome and let body fill the frame
登录态实测(Edge + 真实 TinyMCE)复现了上一版没修好的两点:

1. 占位符仍不显示:editor-runtime 会把块级删除浮层插进 body,它带
   data-mce-bogus 但含「✕ 选中此块」文字,body.textContent 因此永远非空,
   data-jio-empty 一直没被打上。判断正文是否为空时先剔除 data-mce-bogus 节点。

2. 点空白落不到正文:body 高度只有 29px。`min-height:100%` 的父级 html
   没有确定高度,百分比退化成 auto。改为 html{height:100%} +
   body{min-height:100%},body 现在铺满 520px 的 iframe。

实测结果(登录态 https://localhost/submit/):
- 首次加载 data-jio-empty=1、::before 渲染「请输入正文」;
- 点击正文中部空白,光标落进 P 并可继续输入;
- 引用块内编辑后点空白,光标落到引用之后的段落;
- 清空内容后占位符恢复。

测试:新增「编辑器辅助节点不算正文」回归用例;900 → 901 全通过。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 21:16:45 +08:00
kate522andClaude Opus 5 5afa7ab9df fix(submit): show body placeholder on first load and restore caret on blank clicks
两个前台投稿编辑器的缺陷,根因都在占位符的实现方式:

1. 首次加载不显示占位符,输入一个再删掉才出现。
   旧实现往正文插了一个 data-mce-bogus 占位段落,而 TinyMCE 在
   setContent(studio 初始化时必调)与清理 bogus 元素时会把它移除。

2. 光标在块级结构里时,点击正文空白处无法落回正文。
   占位段落占着首行、且 pointer-events:none,点击落不到可编辑元素上;
   正文以表格 / 代码块这类结构块结尾时也没有可承载光标的段落。

改为 front-submit-editor-basics.js(替换 front-submit-placeholder.js):
- 占位符改成 body 属性 + content CSS 的 ::before,正文 DOM 不含占位节点;
- 点击空白处(事件目标是 body)且光标不在普通文本里时,补一个可编辑尾段
  并把光标放进去;
- 两份 content CSS 让 html/body 撑满编辑区,studio 的 syncEditorHeight
  以编辑器声明高度为下限,空正文时 iframe 不会缩成一行。

新增 tests/widget-system/submit-placeholder-behavior.test.cjs(jsdom 跑真实插件)。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 20:38:02 +08:00
kate522andClaude Opus 5 44a03fd5f4 fix(submit): render the configured body placeholder in TinyMCE
WordPress 打包的 TinyMCE 4.9 不含官方 placeholder 插件,tinymce.init 里的
placeholder 配置被静默忽略,投稿页「投稿内容占位符」从未显示过。

新增主题插件 assets/js/front-submit-placeholder.js:正文为空时插入一个
data-mce-bogus 的占位段落,有内容即移除;序列化 / 解析都剔除该段落,
字数统计也跳过它,提示文字不会写进文章。

- 经典投稿表单与创作者工作台都通过 external_plugins 加载
  (WordPress 会丢弃名字已在 plugins 列表里的外部插件)
- 占位样式写进 iframe 的 content CSS:submit-editor.css 与
  editor-content-style.ts

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 19:01:28 +08:00
kate522andClaude Opus 5 beb898b1ab fix(creator-studio): caret overlap in toolbar and hidden sub-categories
工具条下拉触发器的下三角原本绝对定位在按钮右下角,按钮宽度不够时会压到
居中的文字上。改为文字 + 三角同行排版(.jio-creator__tool-meta),宽度不足
时只压缩文字。

分类只查询 parent=0,导致二级 / 三级分类在投稿页完全不可选。新增
SubmitCategories 统一解析:
- 取全部分类并按父子关系深度优先展平,带上 depth / path;
- 白名单按"选了上级即包含其全部子级"展开,未配置白名单时不做额外过滤;
- 创作者工作台、经典投稿表单、保存校验与审核应用共用同一份结果。

选择器按 depth 缩进,搜索同时匹配完整路径。

同时把 assets/creator-studio/build 与 assets/admin/build 统一为整目录忽略
(不再跟踪 .gitkeep),避免构建产物反复被误提交。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 18:10:19 +08:00
kate522andClaude Opus 5 330df53195 feat(creator-studio): multi-select category picker and creatable tag input
分类从平铺复选标签改为带搜索的多选下拉(触发器内是已选令牌),
标签改为令牌输入框:回车 / 逗号 / 顿号 / 分号 / 换行切分,输入时列出
站点已有标签作为建议,面板内可一键新建。

- 抽出 useAnchoredPanel,工具条下拉与新的选择器共用同一套 portal 定位
- bootstrap 的 tags 增加 suggestions(按使用量取前 200 个已有标签)
- 清理 .jio-creator-inline 与 chip 内的死样式

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-09 17:35:52 +08:00
kate522 8bb4b98fc9 chore(creator-studio): stop tracking the build output
assets/creator-studio/build is generated by `npm run build`, so committing it
put a rebuilt bundle in every diff. It now follows the same deploy-only rule
as assets/admin/build.

- Root .gitignore ignores build/* and node_modules/, keeping a .gitkeep so
  the directory still exists in a clean checkout.
- Drops the three tracked artifacts from the index.
- The contract test no longer requires the artifacts to exist; it checks the
  set is all-or-nothing, so a clean checkout and a locally built tree both
  pass. This mirrors admin-build-graph-contract.
- README documents that build/ is produced on the target machine.

887 widget-system tests pass.
2026-11-09 16:44:41 +08:00
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
kate522 f97fd72bd0 refactor(creator-studio): move taxonomy to the settings card, slim the drawer to pay
Classification belongs next to everything else the author decides before
publishing, and the drawer should only configure paid resources.

- PublishSettings now renders categories, tags and custom taxonomy
  dimensions first, then cover, paid content and scheduling. Chips use a
  stacked row layout so long category lists wrap naturally.
- PublishDrawer keeps only PayPanel: taxonomy, save/publish buttons and the
  now-unused props are gone, leaving a single 完成 button.
- New PublishDialog takes over the publish action from the bottom bar, and
  with it the captcha mount point, so the gate still renders somewhere the
  author can see it.
- Promotes .jio-creator-primary / .jio-creator-ghost out of the dialog-only
  rules (drawer and pay panel buttons had no styling), and drops the dead
  .jio-creator-field / .jio-creator-cover blocks.

Contracts updated; 886 widget-system tests pass.
2026-11-09 15:47:02 +08:00
kate522 ac84e991d1 feat(creator-studio): pay toggle and entry in the publish settings card
The card below the writing surface only offered cover and scheduling, so
paid content could only be reached through the bottom bar's 发布 button.

- The card gains a 付费内容 row (rendered only with canPay): a toggle bound
  to draft.pay.enabled, a status line that reflects whether resources were
  added, and a 配置价格与付费资源 link.
- Turning the toggle on opens the publish drawer and scrolls it to the pay
  section, so pricing is the next thing the author sees. Entering from the
  bottom bar keeps the drawer at the top.
2026-11-09 15:31:08 +08:00
kate522 0e4e4670dd feat(creator-studio): full pay settings and paid resources in the publish drawer
The drawer only had a pay toggle and one bare price field, so several
options from the front-submit pay card could not be set at all.

- New PayPanel mirrors the front-submit card: cash / points segment
  (points only when the site has credits enabled), price or points with
  the currency suffix, and VIP prices. VIP fields render only when the
  site asks for manual VIP pricing and the level is enabled, and now
  submit vip1_points / vip2_points as well.
- New ResourceDialog restores "添加资源": download URL with an attachment
  picker, resource note (extraction code), copy name / value, custom
  button label and button style swatches. Pasting a net-disk share link
  splits the URL and the extraction code.
- pay.ts sends every download display field and tags net-disk links.
- CreatorRest exposes vipManual / vip*Enabled / vip names / pointsEnabled
  / downloadClasses / currencySymbol, and the readback carries
  extractCode / copyKey / copyVal / class / attachmentId.
- Fixes an existing data loss: snapshot_from_payload dropped copy_key,
  copy_val, class and attachment_id, so approving a revision erased them.

Files split to stay within budget: publish-drawer 332 lines, pay-panel
343, resource-dialog 254. 886 widget-system tests pass.
2026-11-09 15:24:30 +08:00
kate522 c5bdbc0457 feat(creator-studio): portal dropdowns, hidden content, two-step block delete
Toolbar
- New ToolMenu renders menus through a portal on body, so they are no longer
  clipped by the horizontally scrolling toolbar and no longer fall back to a
  native <select>. Triggers reuse .jio-creator__tool-btn geometry, fixing the
  heading button's mismatched height/size/position.
- Heading / list / align / quote / hidden-content are all dropdowns.
- Lists: unordered + ordered via InsertOrderedList/InsertUnorderedList.
  The TOC button is removed (it also used the wrong icon).
- Adds left / center / right alignment.
- Adds hidden content: comment / login / VIP / paid, wired to the existing
  [reply], [jio_hide mode="login"], [vip] and [payshow] shortcodes.

Editor content
- Quote blocks now match the live article: full .quote_q structure, four
  colour variables, and an SVG-mask quote mark that does not depend on the
  Font Awesome font being present inside the iframe.
- Block math is centred on a transparent background instead of a full-width
  grey bar.
- Code blocks are plain <pre><code>, identical to the article page; language
  and theme selection is gone and EnlighterJS handles highlighting globally.
  The classic submit editor's code modal follows the same shape.
- Hidden content reuses the .tinymce-hide structure and shows a readable label
  while keeping the shortcode text in the DOM for saving.

Block deletion
- Two-step delete, WPS style: the first click only selects and highlights the
  block, the second click removes it. Clicking elsewhere or Esc cancels.

Contracts updated and extended; 884 widget-system tests pass.
2026-11-09 15:03:50 +08:00
kate522andClaude Opus 5 3e48fdf61e fix(creator-studio): hide block-delete overlay inside the editor iframe
块级删除浮层插在 TinyMCE 的 iframe 里,但隐藏规则只写在父页面样式表,
iframe 是独立文档、拿不到这些样式,于是 opacity:0 / position:absolute 全部
失效,✕ 退化成正文顶部的常显元素。

- 把 #jio-block-actions 的定位与隐藏规则移入 content_style,并给 body 加
  position:relative 作为定位基准;隐藏时 pointer-events:none 避免挡住正文
- 浮层加 data-mce-bogus="all",让 TinyMCE 在序列化、字数和选区计算时跳过它,
  否则 ✕ 会被写进保存内容
- 删除 _block-tools.scss 中作用于同一选择器的页面级死样式
- 契约测试锁定「样式必须在 content_style」与 bogus 属性

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-08 22:36:57 +08:00
kate522andClaude Opus 5 1970db0b56 feat(creator-studio): two-row masthead with site logo and user avatar
顶栏改为知乎式两行结构:第一行左侧站点 LOGO、右侧当前用户头像,
第二行只保留正文工具条并居中,同时移除「Jio / 写文章」字样。

- bootstrap payload 新增 site/viewer 身份字段(复用 jio_get_site_logo_url
  与 jio_get_avatar_url,前端不拼 URL、不做权限判断)
- 拆分 draft 类型、TinyMCE 块运行时、顶栏组件,index.tsx 1065 → 735 行
- 清理死代码:未调用的 keepCaretInsideCode、永远无法打开的代码语言弹窗
  (setCodeLanguage 只会收到 null,codeTargetRef 从未赋值)及其样式,
  以及顶栏移除后失效的 bar-left/brand/mode/save-draft/ghost/primary 规则
- 契约测试、本地预览与截图脚本同步到新 DOM

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-08 22:20:10 +08:00
kate522andClaude Opus 5 5f31c58df2 fix(front-submit): let drafts save with partial content
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-07 00:58:13 +08:00
kate522andClaude Opus 5 4a119358ca feat(creator-studio): bottom status bar, editor-rendered math/footnote, code language picker, block delete
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-07 00:38:39 +08:00
kate522andClaude Opus 5 6928127bfa fix(creator-studio): render math/footnote shortcodes, inline code blocks, block deletion
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 23:52:39 +08:00
kate522andClaude Opus 5 7885f42cff feat(creator-studio): dialog-driven table/math/footnote, theme quote, code language picker
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 23:23:59 +08:00
kate522andClaude Opus 5 7c33482be7 feat(creator-studio): icon toolbar with block tools, drop author strip
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 22:30:08 +08:00
kate522andClaude Opus 5 7bdf7cf018 feat(creator-studio): centered paper layout and scheduled publishing
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 21:33:40 +08:00
kate522andClaude Opus 5 384d2b7aa0 feat(creator-studio): switch writing editor to TinyMCE
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 20:51:18 +08:00
kate522andClaude Opus 5 4868de2cda fix(creator-studio): 加载正文编辑格式工具栏
选中文字时的 RichText 加粗、斜体、链接等工具由 WordPress format-library 注册。
BlockTools 虽然提供 inline toolbar slot,但此前前台没有加载 wp-format-library,
因此正文选区没有格式工具。为 Creator Studio 前台显式加载该 script/style handle,
并将行内格式工具栏统一为深色圆角悬浮样式。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 17:59:17 +08:00
kate522andClaude Opus 5 9e8913ea0a fix(creator-studio): 固定公众号式创作工具栏
- 顶部改为 fixed 创作工具栏:左侧返回/品牌/模式,中间文章标题与保存状态,
  右侧撤销/重做、保存草稿、预览、发布
- 新增工作台级撤销/重做快照栈,连续编辑合并记录;支持 Ctrl/Cmd+Z / Shift+Z,
  不覆盖 RichText 输入框自身的编辑历史
- 移动端收敛工具栏布局,保留撤销/重做、预览、发布
- 先保存草稿再请求审核/直接发布;请求使用服务端更新后的文章与版本 ID
- 固定工具栏以独立 chrome 层布局,正文避开顶部工具栏高度
- 补充固定工具栏、历史操作与键盘快捷键契约

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 17:36:15 +08:00
kate522andClaude Opus 5 f5e9420266 feat(creator-studio): 图片宽度四档与作者行
- 通过 editor.BlockEdit 过滤器给 core/image 增加「半屏 / 中等 / 通栏 / 全宽」
  四档宽度,选中图片时出现在区块工具条;宽度写入 className 并序列化到
  post_content,前台样式即可生效,无需自定义区块或额外元数据
- 前台样式:半屏靠左 50%,中等 72%,通栏跟随正文行宽,全宽突破行宽但受容器
  内边距约束;移动端半屏与全宽回退为整行,避免横向滚动
- 新增作者行(头像 + 昵称 + 身份说明),数据由 CreatorRest::author_payload()
  从服务端给出,前端不自行拼装;无昵称时整行不渲染,头像缺失时回退首字占位
- 作者行放在摘要之后、正文之前

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 16:05:19 +08:00
kate522andClaude Opus 5 79909f449e feat(creator-studio): 公众号式插入面板与封面条
- 新增常驻「添加内容」按钮与插入面板:分组网格列出正文/标题/列表/引用、
  图片/视频/嵌入、代码/分隔线/表格/付费内容;条目不满足能力时不出现在面板里
- 面板支持方向键在网格内移动焦点、Esc 关闭;桌面居中浮层,移动端贴底抽屉并
  留出安全区
- 空文档插入区块时替换初始空白段落,不留空行
- 新增封面条:无封面时给低调入口,有封面时显示 2.35:1 缩略图,悬停出现
  「更换封面」,右上角可移除
- 补充契约测试:头部/页脚/挂件区开关、插入面板真实区块名与能力过滤、
  中文字数口径

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 15:57:44 +08:00
kate522andClaude Opus 5 d07cffe99e fix(creator-studio): 沉浸式布局与公众号式写作体验
首轮实机体验暴露的问题:

- 投稿页仍在渲染主题头部的 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) <noreply@anthropic.com>
2026-11-06 15:49:57 +08:00
kate522andClaude Opus 5 2c7262770b fix(creator-studio): 修复白屏与前台 REST 鉴权
白屏根因:CreatorRest / SubmissionVersion 位于 Jio\Core 命名空间,
但调用 Jio\Content\PrivateAssets 时缺少 use 导入,PHP 就近解析为不存在的
Jio\Core\PrivateAssets,在 wp_head 中抛致命错误导致页面输出截断。

- 为 CreatorRest、SubmissionVersion 补上 use Jio\Content\PrivateAssets
- 新增前台 api-fetch nonce 中间件:WordPress 只在后台注入 wpApiSettings,
  前台工作台里 Gutenberg core-data 请求(/wp/v2/users/me)因此全部 403
- 提交前先落一次草稿,避免自动保存未触发时发布到旧内容
- 新增 tools/check-class-refs.php:静态检测命名空间内未导入的裸类引用
- 新增 assets/creator-studio/scripts/smoke.cjs:浏览器冒烟脚本,
  抓控制台错误、失败请求与未捕获的 Promise 拒绝

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 15:39:10 +08:00
kate522andClaude Opus 5 fac4a714e0 feat(creator-studio): 前台 Gutenberg 创作工作台与受保护付费附件
前台投稿页改为沉浸式创作工作台:Gutenberg 负责区块解析与序列化,
React + TypeScript 负责工作台外壳与发布抽屉,Jio 服务端继续作为权限、
审核与付费的唯一权威。

- 新增 assets/creator-studio 独立构建(wp-scripts,锁定 WP 6.4 时代包),
  仅在投稿模板加载,构建缺失或游客访问时回退原有 TinyMCE 表单
- 自动保存(4s 防抖 + rev 冲突 409)、本地快照恢复、发布配置抽屉、
  移动端全屏单列与安全区适配
- 图片插入走现有 front-submit 上传管线,保留能力校验与待认领生命周期
- 已发布文章的改稿写入私有版本,审核通过前线上内容/链接/付费条款不变;
  原生后台「改稿审核」一次性应用或退回,并校验源文章并发指纹
- 私有附件新表 jio_private_asset + jio_dl_token.asset_id,schema 升到 3.4.0;
  文件存放 ABSPATH 之外,未配置私有存储时 fail closed
- 下载令牌绑定文章/附件/用户/IP/UA/次数,每次交付复核 Visibility 的
  订单、VIP 与配额判定;中断传输归还次数
- 付费字段改为写入前校验,非法价格不再留下半保存文章
- 新增 creator-studio 契约测试;更新受影响的 schema/下载/投稿契约

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 14:53:23 +08:00