mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
Keep editor caption geometry stable during block selection
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
{ "preset": ["default", { "discardComments": { "removeAll": false } }] }
|
|
||||||
@@ -24,5 +24,15 @@
|
|||||||
"@playwright/test": "1.64.0",
|
"@playwright/test": "1.64.0",
|
||||||
"@wordpress/env": "11.17.0",
|
"@wordpress/env": "11.17.0",
|
||||||
"@wordpress/scripts": "36.1.0"
|
"@wordpress/scripts": "36.1.0"
|
||||||
|
},
|
||||||
|
"cssnano": {
|
||||||
|
"preset": [
|
||||||
|
"default",
|
||||||
|
{
|
||||||
|
"discardComments": {
|
||||||
|
"removeAll": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ const readme = await readFile(path.join(root, 'readme.txt'), 'utf8');
|
|||||||
if (!php.includes(`Version: ${pkg.version}`) || !readme.includes(`Stable tag: ${pkg.version}`)) throw new Error('Version headers disagree.');
|
if (!php.includes(`Version: ${pkg.version}`) || !readme.includes(`Stable tag: ${pkg.version}`)) throw new Error('Version headers disagree.');
|
||||||
const temp = await mkdtemp(path.join(os.tmpdir(), 'wp-asciiplayer-package-'));
|
const temp = await mkdtemp(path.join(os.tmpdir(), 'wp-asciiplayer-package-'));
|
||||||
const target = path.join(temp, 'wp-asciiplayer');
|
const target = path.join(temp, 'wp-asciiplayer');
|
||||||
const inputs = ['asciicast-player.php', 'includes', 'build', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', '.cssnanorc.json', 'babel.config.json', 'scripts'];
|
const inputs = ['asciicast-player.php', 'includes', 'build', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', 'babel.config.json', 'scripts'];
|
||||||
try {
|
try {
|
||||||
await mkdir(target);
|
await mkdir(target);
|
||||||
for (const file of inputs) await cp(path.join(root, file), path.join(target, file), { recursive: true });
|
for (const file of inputs) await cp(path.join(root, file), path.join(target, file), { recursive: true });
|
||||||
|
|||||||
+1
-1
@@ -100,7 +100,7 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
|||||||
{ source && <Button variant="secondary" onClick={ () => { setApprovedSource( source ); setAttempt( ( current ) => current + 1 ); } }>{ __( 'Load preview', 'wp-asciiplayer' ) }</Button> }
|
{ source && <Button variant="secondary" onClick={ () => { setApprovedSource( source ); setAttempt( ( current ) => current + 1 ); } }>{ __( 'Load preview', 'wp-asciiplayer' ) }</Button> }
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
) }
|
) }
|
||||||
{ ( isSelected || caption ) && <RichText tagName="figcaption" className="wp-element-caption" 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>
|
||||||
{ approvedSource === source && source && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
|
{ approvedSource === source && source && <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> }
|
||||||
|
|||||||
@@ -58,3 +58,8 @@
|
|||||||
.asciiplayer-example__terminal > span:first-child { color: #a9da76; }
|
.asciiplayer-example__terminal > span:first-child { color: #a9da76; }
|
||||||
.asciiplayer-example__controls { padding: 8px 16px; background: #222; font: 12px/1.5 monospace; }
|
.asciiplayer-example__controls { padding: 8px 16px; background: #222; font: 12px/1.5 monospace; }
|
||||||
.asciiplayer-example figcaption { padding: 8px; background: #fff; color: #333; text-align: center; font-size: 12px; }
|
.asciiplayer-example figcaption { padding: 8px; background: #fff; color: #333; text-align: center; font-size: 12px; }
|
||||||
|
|
||||||
|
/* Keep an empty caption's footprint stable when another block is selected.
|
||||||
|
* Removing it on pointerdown can move the next block's button before pointerup. */
|
||||||
|
.asciiplayer-editor .asciiplayer-figure > figcaption { min-height: 1.5em; }
|
||||||
|
.asciiplayer-editor .asciiplayer-caption-empty { visibility: hidden; }
|
||||||
|
|||||||
Reference in New Issue
Block a user