From 41395f4102585794e1dc9328419f39a1ac7fb1fd Mon Sep 17 00:00:00 2001 From: LamGC Date: Wed, 14 Oct 2026 09:59:55 +0800 Subject: [PATCH] Move block explanations into collapsed sidebar help (1.2.3) --- README-zh.md | 2 ++ README.md | 2 ++ asciicast-player.php | 4 ++-- block.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 5 ++++- src/edit.js | 6 ++++-- tests/e2e/asciiplayer.spec.js | 17 +++++++++++++++-- tests/php/run.php | 4 ++-- 10 files changed, 35 insertions(+), 13 deletions(-) diff --git a/README-zh.md b/README-zh.md index 1ab0ec9..a0495cc 100644 --- a/README-zh.md +++ b/README-zh.md @@ -60,3 +60,5 @@ URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页 浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。 上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。 + +1.2.3 将区块内常驻的录制/隐私说明和播放操作说明移至侧栏默认折叠的 **Help** 面板,保留标题、错误提示和必要控件标签。 diff --git a/README.md b/README.md index f299665..ede031c 100644 --- a/README.md +++ b/README.md @@ -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 not start a recording request. 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. Terminal typography is scoped against common theme `pre`/`span` styles so diff --git a/asciicast-player.php b/asciicast-player.php index 37ea1cb..93e31f8 100644 --- a/asciicast-player.php +++ b/asciicast-player.php @@ -3,7 +3,7 @@ * Plugin Name: Asciicast Player * Plugin URI: https://github.com/LamGC/wp-asciiplayer * 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 PHP: 7.4 * Author: LamGC @@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -const VERSION = '1.2.2'; +const VERSION = '1.2.3'; const PLUGIN_FILE = __FILE__; const SHORTCODE = 'asciiplayer'; diff --git a/block.json b/block.json index c68f497..20e774d 100644 --- a/block.json +++ b/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "lamgc/asciiplayer", - "version": "1.2.2", + "version": "1.2.3", "title": "Asciicast Player", "category": "media", "icon": "editor-code", diff --git a/package-lock.json b/package-lock.json index fdd000b..c80ddfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wp-asciiplayer", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wp-asciiplayer", - "version": "1.2.2", + "version": "1.2.3", "license": "GPL-3.0-only", "dependencies": { "asciinema-player": "3.17.0" diff --git a/package.json b/package.json index 67e0be6..81f6258 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-asciiplayer", - "version": "1.2.2", + "version": "1.2.3", "private": true, "description": "Native WordPress asciicast block with real playback previews and compatible shortcodes", "type": "module", diff --git a/readme.txt b/readme.txt index 1ae4f2c..001d10d 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: asciicast, asciiplayer, asciinema, terminal, block Requires at least: 6.3 Tested up to: 7.1 Requires PHP: 7.4 -Stable tag: 1.2.2 +Stable tag: 1.2.3 License: GPL-3.0-only 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 == += 1.2.3 = +* Move recording/privacy and playback explanations from the block canvas to a collapsed sidebar Help panel. + = 1.2.2 = * Show original cast dimensions as toolbar/sidebar placeholders without forcing overrides. * Refresh recording metadata when the URL changes, reusing the preview request. diff --git a/src/edit.js b/src/edit.js index 6adbc7a..dac2679 100644 --- a/src/edit.js +++ b/src/edit.js @@ -135,6 +135,10 @@ export default function Edit( { attributes, setAttributes, isSelected } ) { setAttributes( { fit: value } ) } /> { attributes.legacyStyle &&

{ __( 'The custom container style from your shortcode is preserved on the published page.', 'wp-asciiplayer' ) }

} + +

{ __( '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' ) }

+

{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }

+
@@ -148,7 +152,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) { ) } /> { mediaError && { __( 'Choose an Asciicast (.cast) file from the Media Library.', 'wp-asciiplayer' ) } } -

{ __( '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' ) }

{ urlError && { __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) } }
@@ -161,7 +164,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) { ) } setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
- { showPreview &&

{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }

} { [ 'height', 'both' ].includes( fit ) &&

{ __( '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' ) }

}
diff --git a/tests/e2e/asciiplayer.spec.js b/tests/e2e/asciiplayer.spec.js index 1acc889..54dae49 100644 --- a/tests/e2e/asciiplayer.spec.js +++ b/tests/e2e/asciiplayer.spec.js @@ -267,8 +267,21 @@ test('a saved Recording URL loads once without a click and never autoplays in th await readyPreview(block); 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('.asciiplayer-editor__privacy')).toContainText(/automatic/i); - await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/server/i); + await expect(block.locator('.asciiplayer-editor__privacy')).toHaveCount(0); + 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. expect(requests).toEqual([source]); await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible(); diff --git a/tests/php/run.php b/tests/php/run.php index f59fca8..fc3969d 100644 --- a/tests/php/run.php +++ b/tests/php/run.php @@ -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.' ); 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.' ); - contains( 'player.js?ver=1.2.2', $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.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.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. 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:secret@example.test/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {