Move block explanations into collapsed sidebar help (1.2.3)

This commit is contained in:
2026-10-14 09:59:55 +08:00
parent 85474494b1
commit 41395f4102
10 changed files with 35 additions and 13 deletions
+2
View File
@@ -60,3 +60,5 @@ URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页
浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。 浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。
上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。 上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。
1.2.3 将区块内常驻的录制/隐私说明和播放操作说明移至侧栏默认折叠的 **Help** 面板,保留标题、错误提示和必要控件标签。
+2
View File
@@ -36,6 +36,8 @@ 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
**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.
Terminal typography is scoped against common theme `pre`/`span` styles so Terminal typography is scoped against common theme `pre`/`span` styles so
+2 -2
View File
@@ -3,7 +3,7 @@
* Plugin Name: Asciicast Player * Plugin Name: Asciicast Player
* Plugin URI: https://github.com/LamGC/wp-asciiplayer * Plugin URI: https://github.com/LamGC/wp-asciiplayer
* Description: Add interactive terminal recordings to posts and pages with a block or shortcode. * Description: Add interactive terminal recordings to posts and pages with a block or shortcode.
* Version: 1.2.2 * Version: 1.2.3
* Requires at least: 6.3 * Requires at least: 6.3
* Requires PHP: 7.4 * Requires PHP: 7.4
* Author: LamGC * Author: LamGC
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
const VERSION = '1.2.2'; const VERSION = '1.2.3';
const PLUGIN_FILE = __FILE__; const PLUGIN_FILE = __FILE__;
const SHORTCODE = 'asciiplayer'; const SHORTCODE = 'asciiplayer';
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json", "$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3, "apiVersion": 3,
"name": "lamgc/asciiplayer", "name": "lamgc/asciiplayer",
"version": "1.2.2", "version": "1.2.3",
"title": "Asciicast Player", "title": "Asciicast Player",
"category": "media", "category": "media",
"icon": "editor-code", "icon": "editor-code",
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "wp-asciiplayer", "name": "wp-asciiplayer",
"version": "1.2.2", "version": "1.2.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "wp-asciiplayer", "name": "wp-asciiplayer",
"version": "1.2.2", "version": "1.2.3",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"asciinema-player": "3.17.0" "asciinema-player": "3.17.0"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "wp-asciiplayer", "name": "wp-asciiplayer",
"version": "1.2.2", "version": "1.2.3",
"private": true, "private": true,
"description": "Native WordPress asciicast block with real playback previews and compatible shortcodes", "description": "Native WordPress asciicast block with real playback previews and compatible shortcodes",
"type": "module", "type": "module",
+4 -1
View File
@@ -4,7 +4,7 @@ Tags: asciicast, asciiplayer, asciinema, terminal, block
Requires at least: 6.3 Requires at least: 6.3
Tested up to: 7.1 Tested up to: 7.1
Requires PHP: 7.4 Requires PHP: 7.4
Stable tag: 1.2.2 Stable tag: 1.2.3
License: GPL-3.0-only License: GPL-3.0-only
License URI: https://www.gnu.org/licenses/gpl-3.0.html License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -55,6 +55,9 @@ Existing shortcodes work in the Classic Editor. The new visual controls and inli
== Changelog == == Changelog ==
= 1.2.3 =
* Move recording/privacy and playback explanations from the block canvas to a collapsed sidebar Help panel.
= 1.2.2 = = 1.2.2 =
* Show original cast dimensions as toolbar/sidebar placeholders without forcing overrides. * Show original cast dimensions as toolbar/sidebar placeholders without forcing overrides.
* Refresh recording metadata when the URL changes, reusing the preview request. * Refresh recording metadata when the URL changes, reusing the preview request.
+4 -2
View File
@@ -135,6 +135,10 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
<SelectControl label={ __( 'Fit', 'wp-asciiplayer' ) } value={ fit } options={ fitOptions } help={ [ 'height', 'both' ].includes( fit ) ? __( 'Height-based fitting requires a fixed container height in your site CSS.', 'wp-asciiplayer' ) : undefined } onChange={ ( value ) => setAttributes( { fit: value } ) } /> <SelectControl label={ __( 'Fit', 'wp-asciiplayer' ) } value={ fit } options={ fitOptions } help={ [ 'height', 'both' ].includes( fit ) ? __( 'Height-based fitting requires a fixed container height in your site CSS.', 'wp-asciiplayer' ) : undefined } onChange={ ( value ) => setAttributes( { fit: value } ) } />
{ attributes.legacyStyle && <p>{ __( 'The custom container style from your shortcode is preserved on the published page.', 'wp-asciiplayer' ) }</p> } { attributes.legacyStyle && <p>{ __( 'The custom container style from your shortcode is preserved on the published page.', 'wp-asciiplayer' ) }</p> }
</PanelBody> </PanelBody>
<PanelBody title={ __( 'Help', 'wp-asciiplayer' ) } initialOpen={ false }>
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
<p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p>
</PanelBody>
</InspectorControls> </InspectorControls>
<div { ...blockProps }> <div { ...blockProps }>
<div className="asciiplayer-editor__source"> <div className="asciiplayer-editor__source">
@@ -148,7 +152,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
) } /> ) } />
</MediaUploadCheck> </MediaUploadCheck>
{ mediaError && <Notice status="error" isDismissible={ false }>{ __( 'Choose an Asciicast (.cast) file from the Media Library.', 'wp-asciiplayer' ) }</Notice> } { mediaError && <Notice status="error" isDismissible={ false }>{ __( 'Choose an Asciicast (.cast) file from the Media Library.', 'wp-asciiplayer' ) }</Notice> }
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
{ urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> } { urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> }
</div> </div>
<figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }> <figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }>
@@ -161,7 +164,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
) } ) }
<RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } /> <RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
</figure> </figure>
{ showPreview && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
{ [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> } { [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> }
</div> </div>
</> </>
+15 -2
View File
@@ -267,8 +267,21 @@ test('a saved Recording URL loads once without a click and never autoplays in th
await readyPreview(block); await readyPreview(block);
await expect(block.getByRole('button', { name: 'Load preview', exact: true })).toHaveCount(0); await expect(block.getByRole('button', { name: 'Load preview', exact: true })).toHaveCount(0);
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible(); await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i); await expect(block.locator('.asciiplayer-editor__privacy')).toHaveCount(0);
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/server/i); await expect(block.locator(':scope > .asciiplayer-editor__hint')).toHaveCount(0);
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toBeVisible();
await expect(block.getByRole('button', { name: 'Choose recording', exact: true })).toBeVisible();
await expect(block.locator('figcaption[contenteditable="true"]')).toBeVisible();
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
const helpToggle = page.locator('.components-panel__body-toggle').filter({ hasText: /^Help$/ });
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
await helpToggle.click();
const help = page.locator('.components-panel__body').filter({ has: helpToggle });
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
await expect(help).toContainText('Use the player controls to play, pause, and seek.');
await helpToggle.click();
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
await page.waitForTimeout(750); // Catch a second fetch from a pending debounce. await page.waitForTimeout(750); // Catch a second fetch from a pending debounce.
expect(requests).toEqual([source]); expect(requests).toEqual([source]);
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible(); await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
+2 -2
View File
@@ -60,8 +60,8 @@ try {
same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' ); same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' );
contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' ); contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' );
same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' ); same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' );
contains( 'player.js?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' ); contains( 'player.js?ver=1.2.3', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
contains( 'player.css?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' ); contains( 'player.css?ver=1.2.3', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
// Source validation covers script, HTML, credential and relative-URL attacks. // Source validation covers script, HTML, credential and relative-URL attacks.
foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) { foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {