docs: structure bilingual readmes with semantic Markdown

This commit is contained in:
2026-10-14 17:24:55 +08:00
parent f6079d38fd
commit 7ab9fcf8d1
2 changed files with 142 additions and 58 deletions
+78 -26
View File
@@ -3,6 +3,8 @@
为 WordPress 提供原生 Asciicast Player 区块,可在编辑器内真实播放终端录屏, 为 WordPress 提供原生 Asciicast Player 区块,可在编辑器内真实播放终端录屏,
同时兼容原有 `[asciiplayer]` shortcode。 同时兼容原有 `[asciiplayer]` shortcode。
[English documentation](README.md)
## 界面语言 ## 界面语言
插件自己的界面支持英文和简体中文(`zh_CN`)。编辑器跟随「用户 → 个人资料 → 语言」 插件自己的界面支持英文和简体中文(`zh_CN`)。编辑器跟随「用户 → 个人资料 → 语言」
@@ -10,39 +12,66 @@
英文为默认回退语言。不会把 `zh_TW` 等其他中文地区设置自动映射为简体中文。 英文为默认回退语言。不会把 `zh_TW` 等其他中文地区设置自动映射为简体中文。
录屏中的终端内容和作者填写的说明文字不会被翻译。上游播放器自身的播放控件和帮助仍为英文,播放器文件保持原样。 录屏中的终端内容和作者填写的说明文字不会被翻译。上游播放器自身的播放控件和帮助仍为英文,播放器文件保持原样。
## 安装与使用 ## 安装
1. 将构建得到的 `wp-asciiplayer.zip` 上传到 **插件 → 安装插件 → 上传插件**。
2. 启用插件。
将构建得到的 `wp-asciiplayer.zip` 上传到「插件 → 安装插件 → 上传插件」并启用。
GitHub 源码 ZIP 需要先构建,不能直接当发行包安装。构建方法见 [SOURCE.md](SOURCE.md)。 GitHub 源码 ZIP 需要先构建,不能直接当发行包安装。构建方法见 [SOURCE.md](SOURCE.md)。
要求 WordPress 6.3+、PHP 7.4+;具体测试版本见仓库 CI。
插入「Asciicast Player」区块,粘贴录制文件的 HTTP(S) URL,停止输入约半秒后会自动加载预览;也可以点击「Apply URL」立即加载。之后即可在编辑器内播放、 **环境要求:** WordPress 6.3+、PHP 7.4+;具体测试版本见[仓库 CI](.github/workflows/ci.yml)。
暂停和拖动。「Display」面板提供展示宽度预设、自定义宽度(例如 `480px`、`65%`)以及左、中、右对齐;
展示宽度会限制在当前页面可用空间内。点击播放器下方即可添加描述文字。 ## 区块编辑器
1. 插入 **Asciicast Player** 区块。
2. 粘贴录制文件的 HTTP(S) URL,停止输入约半秒后会自动加载预览;
也可以点击 **Apply URL** 立即加载。
3. 之后即可在编辑器内播放、暂停和拖动。
4. **Display** 面板提供展示宽度预设、自定义宽度(例如 `480px`、`65%`)以及左、中、右对齐;
展示宽度会限制在当前页面可用空间内。
5. 点击播放器下方即可添加描述文字。
### 终端尺寸
在区块上方浮动工具栏点击 **Terminal size** 可快速调整终端行列数;侧边栏的同名折叠面板也保留,两处设置实时同步。
- 终端尺寸与展示大小分别控制:**Columns** / **Rows** 留空时,使用 cast 文件记录的终端尺寸,
并跟随录制中的 resize 事件。只有需要改变终端网格时才覆盖行列数,点击 **Use recording size** 可恢复。
- 展示宽度与 `fit: width` 只缩放画面,不会修改终端行列数;覆盖网格可能影响录屏排版或裁切内容。
在区块上方浮动工具栏点击「Terminal size」可快速调整终端行列数;侧边栏的同名折叠面板也保留,两处设置实时同步。
终端尺寸与展示大小分别控制:Columns / Rows 留空时,使用 cast 文件记录的终端尺寸,
并跟随录制中的 resize 事件。只有需要改变终端网格时才覆盖行列数,点击「Use recording size」可恢复。
展示宽度与 `fit: width` 只缩放画面,不会修改终端行列数;覆盖网格可能影响录屏排版或裁切内容。
主题、速度、循环、控制栏、起始时间和空闲压缩等选项仍在区块设置中调整。 主题、速度、循环、控制栏、起始时间和空闲压缩等选项仍在区块设置中调整。
保存文章或页面后,前台使用同一播放器。重新打开已有区块时,只要已有有效 URL 就自动加载预览;
编辑预览不会自动播放,前台自动播放设置仍会保留。区块插入器使用本地静态示例,不请求录制文件。 ### 保存与预览行为
保存文章或页面后,前台使用同一播放器。重新打开已有区块时,只要已有有效 URL 就自动加载预览。
编辑预览不会自动播放,前台自动播放设置仍会保留。
区块插入器使用本地静态示例,不请求录制文件。
播放器增加了局部样式隔离,避免常见主题的代码块边框、阴影和字体设置干扰终端;键盘焦点提示仍保留。 播放器增加了局部样式隔离,避免常见主题的代码块边框、阴影和字体设置干扰终端;键盘焦点提示仍保留。
### 录制来源
URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页面地址。跨域文件需要允许 URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页面地址。跨域文件需要允许
来自你站点的 CORS 请求;HTTPS 页面上的 HTTP 文件可能被浏览器阻止。优先使用同源 HTTPS。 来自你站点的 CORS 请求;HTTPS 页面上的 HTTP 文件可能被浏览器阻止。优先使用同源 HTTPS。
本插件不提供远程文件代理、不扩大用户的上传权限,也不创建额外的录屏管理文章类型。 本插件不提供远程文件代理、不扩大用户的上传权限,也不创建额外的录屏管理文章类型。
## 旧文章兼容 ## 旧文章兼容
原有 shortcode 继续有效,无须批量修改文章: 原有 shortcode 继续有效,无须批量修改文章:
[asciiplayer]https://example.org/demo.cast[/asciiplayer] ```text
[asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer] [asciiplayer]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer] [asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
```
布尔值、数值和历史 camelCase 参数会归一化处理;自定义 `style` 经过 WordPress 安全 CSS 过滤。
布尔值、数值和历史 camelCase 参数会归一化处理;自定义 style 经过 WordPress 安全 CSS 过滤。
区块提供 shortcode 转换能力,转换后请检查设置再保存,不会自动重写旧文章。 区块提供 shortcode 转换能力,转换后请检查设置再保存,不会自动重写旧文章。
经典编辑器继续使用 shortcode,暂不增加 TinyMCE 自定义界面。 经典编辑器继续使用 shortcode,暂不增加 TinyMCE 自定义界面。
## 资源与隐私 ## 资源与隐私
@@ -52,20 +81,43 @@ URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页
你选择的录制文件会由读者浏览器直接请求;外部文件主机可能收到 IP、浏览器请求信息和 你选择的录制文件会由读者浏览器直接请求;外部文件主机可能收到 IP、浏览器请求信息和
依浏览器/站点策略发送的来源信息。编辑器存在有效 URL 时也会自动发起这类请求,包括重新打开已保存的区块。 依浏览器/站点策略发送的来源信息。编辑器存在有效 URL 时也会自动发起这类请求,包括重新打开已保存的区块。
请使用可信主机,发布前检查录屏是否包含终端里的敏感信息。外部主机适用其自身隐私政策。 请使用可信主机,发布前检查录屏是否包含终端里的敏感信息。外部主机适用其自身隐私政策。
## 媒体库与原始终端尺寸
### 选择与上传
点击区块中的 **选择录制文件(Choose recording)** 可通过 WordPress 媒体库选择或上传 `.cast` 录制文件。
上传权限沿用 WordPress 的 `upload_files` 能力,不会为低权限用户开放上传。插件仅为经过格式校验的 `.cast` 文件添加支持,不放开任意 JSON、HTML 或 SVG。
### 原始尺寸提示
浮动工具栏和折叠侧栏中的 **Columns** / **Rows** 留空时,会在录制加载后显示原始终端尺寸作为占位提示。
更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。
原始尺寸提示只检查同一次预览响应的前 **64 KiB**,无法读取时保留通用提示。
### 上传限制
上传文件会完整校验:
- 最多 **32 MiB**。
- 最多 **100,000 个事件或流内行**。
- 每条 JSONL 行最多 **256 KiB**。
- 终端任一方向不超过 **1,000**。
旧版 v1 最多 **2 MiB**,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。
v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。
### 区块帮助
区块内常驻的录制/隐私说明和播放操作说明位于侧栏默认折叠的 **帮助(Help)** 面板,保留标题、错误提示和必要控件标签。
## 开发与许可 ## 开发与许可
[构建与测试说明](SOURCE.md) · [第三方许可证](THIRD-PARTY-NOTICES.md) [构建与测试说明](SOURCE.md) · [第三方许可证](THIRD-PARTY-NOTICES.md)
本插件保持 GPL-3.0-only,播放器及依赖保留各自的兼容许可证。 本插件保持 GPL-3.0-only,播放器及依赖保留各自的兼容许可证。
### 媒体库与原始终端尺寸
点击区块中的 **选择录制文件(Choose recording)** 可通过 WordPress 媒体库选择或上传 `.cast` 录制文件。上传权限沿用 WordPress 的 `upload_files` 能力,不会为低权限用户开放上传。插件仅为经过格式校验的 `.cast` 文件添加支持,不放开任意 JSON、HTML 或 SVG。
浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。
上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。
区块内常驻的录制/隐私说明和播放操作说明位于侧栏默认折叠的 **帮助(Help)** 面板,保留标题、错误提示和必要控件标签。
+64 -32
View File
@@ -1,7 +1,9 @@
# wp-asciiplayer # wp-asciiplayer
An Asciicast Player block for WordPress, with real playback in the editor and An Asciicast Player block for WordPress, with real playback in the editor and
backwards-compatible `[asciiplayer]` shortcodes. [中文说明](README-zh.md) backwards-compatible `[asciiplayer]` shortcodes.
[中文说明](README-zh.md)
## Languages ## Languages
@@ -16,65 +18,87 @@ English; its vendor files are not modified.
## Install ## Install
Install the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload 1. Install the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload Plugin**.
Plugin**, then activate **Asciicast Player**. A GitHub source ZIP must be built 2. Activate **Asciicast Player**.
first; it does not contain generated assets. See [SOURCE.md](SOURCE.md).
Requires WordPress 6.3+ and PHP 7.4+. Compatibility must be checked against your A GitHub source ZIP must be built first; it does not contain generated assets. See [SOURCE.md](SOURCE.md).
site and theme; CI tests the versions listed in `.github/workflows/ci.yml`.
**Requirements:** WordPress 6.3+ and PHP 7.4+.
Compatibility must be checked against your site and theme; CI tests the versions
listed in the [CI workflow](.github/workflows/ci.yml).
## Block editor ## Block editor
1. Insert **Asciicast Player**. 1. Insert **Asciicast Player**.
2. Paste an HTTP(S) recording-file URL (for example a `.cast` file), or use **Choose recording** to select/upload a `.cast` file in the WordPress Media Library. The preview loads after a short pause; **Apply URL** loads it immediately. 2. Paste an HTTP(S) recording-file URL (for example a `.cast` file), or use
**Choose recording** to select/upload a `.cast` file in the WordPress Media
Library. The preview loads after a short pause; **Apply URL** loads it immediately.
3. Play, pause and seek in the editor. **Display** offers width presets or a custom 3. Play, pause and seek in the editor. **Display** offers width presets or a custom
CSS length (for example `480px` or `65%`), plus left/center/right alignment. CSS length (for example `480px` or `65%`), plus left/center/right alignment.
The width stays within the available space. Add a caption below the player. The width stays within the available space. Add a caption below the player.
4. Use **Terminal size** in the floating block toolbar for quick Columns/Rows 4. Use **Terminal size** in the floating block toolbar for quick **Columns**/**Rows**
edits, or expand the **Terminal size** sidebar panel. Both edit the same values. edits, or expand the **Terminal size** sidebar panel. Both edit the same values.
Empty fields show the recording’s original columns/rows as placeholders after - Empty fields show the recording’s original columns/rows as placeholders after
loading. Changing the URL refreshes these hints without clearing your explicit loading. Changing the URL refreshes these hints without clearing your explicit
overrides; reset clears overrides, so recorded resize events remain active. overrides; reset clears overrides, so recorded resize events remain active.
Terminal size is separate from display width: leave Columns and Rows blank to use the cast - Terminal size is separate from display width: leave **Columns** and **Rows** blank
file's dimensions and recorded resize events. Override either axis only when to use the cast file's dimensions and recorded resize events. Override either
intentional; use **Use recording size** to clear both. Display width and axis only when intentional; use **Use recording size** to clear both.
`fit: width` scale the existing grid without changing terminal columns. - Display width and `fit: width` scale the existing grid without changing
terminal columns.
5. Change theme, speed, looping, controls, fit, start time and idle-time limit 5. Change theme, speed, looping, controls, fit, start time and idle-time limit
from the remaining block settings. from the remaining block settings.
6. Save the post or page; the same locally bundled player is used on the front end. 6. Save the post or page; the same locally bundled player is used on the front end.
### Preview behavior
Existing saved blocks load their valid recording URL automatically on reopening Existing saved blocks load their valid recording URL automatically on reopening
the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do
not start a recording request. not start a recording request.
Preview does not autoplay even when front-end autoplay is enabled. Preview does not autoplay even when front-end autoplay is enabled.
Recording/privacy and playback explanations are available in the collapsed Recording/privacy and playback explanations are available in the collapsed
**Help** sidebar panel, keeping the block canvas focused on editing. **Help** sidebar panel, keeping the block canvas focused on editing.
The inserter preview is a local static example and never loads a recording. The inserter preview is a local static example and never loads a recording.
### Theme compatibility
Terminal typography is scoped against common theme `pre`/`span` styles so Terminal typography is scoped against common theme `pre`/`span` styles so
character scaling stays aligned with the player grid. A theme with additional character scaling stays aligned with the player grid. A theme with additional
custom rules may still require compatibility testing; keyboard focus indicators custom rules may still require compatibility testing; keyboard focus indicators
remain visible. remain visible.
### Recording source
The source must be a recording-file URL, not an asciinema share-page URL. The source must be a recording-file URL, not an asciinema share-page URL.
A recording on another origin must allow CORS requests from your WordPress site. A recording on another origin must allow CORS requests from your WordPress site.
HTTP recordings on an HTTPS site may be blocked as mixed content. Use a same-site HTTP recordings on an HTTPS site may be blocked as mixed content. Use a same-site
HTTPS URL when possible. The plugin does not proxy or copy remote files, grant HTTPS URL when possible.
new upload capabilities, or add a recording-management post type.
The plugin does not proxy or copy remote files, grant new upload capabilities,
or add a recording-management post type.
## Existing shortcodes ## Existing shortcodes
Old articles remain supported; no content migration is required: Old articles remain supported; no content migration is required:
[asciiplayer]https://example.org/demo.cast[/asciiplayer] ```text
[asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer] [asciiplayer]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer] [asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
```
Boolean and numeric options are typed, and historical camelCase options are Boolean and numeric options are typed, and historical camelCase options are
normalized after WordPress lowercases shortcode attribute names. Inline styles normalized after WordPress lowercases shortcode attribute names. Inline styles
are filtered through WordPress safe-CSS handling; unsafe protocols and markup are filtered through WordPress safe-CSS handling; unsafe protocols and markup
are rejected/escaped. Unsupported executable/object options are not accepted. are rejected/escaped. Unsupported executable/object options are not accepted.
The Classic Editor continues to support shortcodes; it has no custom visual UI. The Classic Editor continues to support shortcodes; it has no custom visual UI.
The block supports a shortcode-to-block transform for supported options. Review The block supports a shortcode-to-block transform for supported options. Review
converted settings before saving; articles are never rewritten automatically. converted settings before saving; articles are never rewritten automatically.
@@ -87,23 +111,25 @@ No analytics or background remote API calls are added.
A recording URL you choose is fetched directly by the visitor's browser. Its host A recording URL you choose is fetched directly by the visitor's browser. Its host
can receive the visitor's IP address, browser request metadata and possibly a can receive the visitor's IP address, browser request metadata and possibly a
referrer, according to browser/site policy. Editor previews have the same effect referrer, according to browser/site policy. Editor previews have the same effect
automatically when a valid URL is present, including when reopening saved blocks. Choose a trusted host and review automatically when a valid URL is present, including when reopening saved blocks.
recordings for sensitive terminal output before publishing them. The host's own
privacy policy applies; the plugin cannot make an external recording private.
## Development Choose a trusted host and review recordings for sensitive terminal output before
publishing them. The host's own privacy policy applies; the plugin cannot make an external recording private.
See [SOURCE.md](SOURCE.md) for locked build and ZIP packaging commands. Source ## Media Library upload limits
code is GPL-3.0-only. The player and its dependencies retain their own compatible
licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
### Media Library upload limits
The plugin adds only `.cast` uploads for users who already have WordPress The plugin adds only `.cast` uploads for users who already have WordPress
`upload_files` permission. On multisite, the network must also allow the `cast` `upload_files` permission. On multisite, the network must also allow the `cast`
extension. Existing site/server upload limits still apply. Each upload is fully extension. Existing site/server upload limits still apply.
validated: at most 32 MiB, 100,000 events/stream lines, 256 KiB per JSONL line, and dimensions
up to 1,000 columns/rows. Legacy v1 is limited to 2 MiB and must be pretty-printed Each upload is fully validated:
- At most **32 MiB**.
- At most **100,000 events/stream lines**.
- At most **256 KiB per JSONL line**.
- Dimensions up to **1,000 columns/rows**.
Legacy v1 is limited to **2 MiB** and must be pretty-printed
with its opening JSON object on a separate line because the bundled player cannot with its opening JSON object on a separate line because the bundled player cannot
read compact single-line v1. v2/v3 use their standard JSONL format. Invalid files read compact single-line v1. v2/v3 use their standard JSONL format. Invalid files
are rejected; generic JSON, HTML and SVG uploads are not enabled. are rejected; generic JSON, HTML and SVG uploads are not enabled.
@@ -111,3 +137,9 @@ are rejected; generic JSON, HTML and SVG uploads are not enabled.
Original-size hints inspect at most the first 64 KiB of the same preview response. Original-size hints inspect at most the first 64 KiB of the same preview response.
If metadata is unavailable, the fields keep a generic placeholder rather than If metadata is unavailable, the fields keep a generic placeholder rather than
guessing dimensions. Recorded resize events do not replace the initial-size hint. guessing dimensions. Recorded resize events do not replace the initial-size hint.
## Development
See [SOURCE.md](SOURCE.md) for locked build and ZIP packaging commands. Source
code is GPL-3.0-only. The player and its dependencies retain their own compatible
licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).