UPDATE Refactor audio player block to remove description handling and add placeholder for caption input
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-10-30 09:41:58 +01:00
parent 2a4bbceeeb
commit 10b0624a29
5 changed files with 14 additions and 20 deletions

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'f1e5510ad5a5a49f9c51');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '05a0d66cc78a35b24dfe');

View File

@ -218,6 +218,7 @@ function Edit({
children: "Audio"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText, {
className: "audio-player__details__caption",
placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Renseignez ici la légende de l'audio", "carhop-blocks"),
value: caption,
onChange: value => handleCaptionChange(value),
tagName: "span"
@ -294,7 +295,6 @@ function save({
const {
audioUrl,
title,
description,
caption
} = attributes;
if (!audioUrl) {
@ -313,17 +313,14 @@ function save({
src: audioUrl,
preload: "metadata",
children: "Votre navigateur ne supporte pas l'\xE9l\xE9ment audio."
}), (description || caption) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("p", {
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("p", {
className: "audio-player__details",
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
className: "audio-player__details__label",
children: "Audio"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
className: "audio-player__details__caption",
children: caption ? caption + " — " : ""
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
className: "audio-player__details__description",
children: description !== null && description !== void 0 ? description : ""
children: caption !== null && caption !== void 0 ? caption : ""
})]
})]
});

File diff suppressed because one or more lines are too long

View File

@ -208,6 +208,10 @@ export default function Edit({ attributes, setAttributes }) {
<span className="audio-player__details__label">Audio</span>
<RichText
className="audio-player__details__caption"
placeholder={__(
"Renseignez ici la légende de l'audio",
"carhop-blocks"
)}
value={caption}
onChange={(value) => handleCaptionChange(value)}
tagName="span"

View File

@ -2,7 +2,7 @@ import { useBlockProps } from "@wordpress/block-editor";
import { RichText } from "@wordpress/block-editor";
export default function save({ attributes }) {
const { audioUrl, title, description, caption } = attributes;
const { audioUrl, title, caption } = attributes;
if (!audioUrl) {
return null;
@ -19,17 +19,10 @@ export default function save({ attributes }) {
Votre navigateur ne supporte pas l'élément audio.
</audio>
{(description || caption) && (
<p className="audio-player__details">
<span className="audio-player__details__label">Audio</span>
<span className="audio-player__details__caption">
{caption ? caption + " — " : ""}
</span>
<span className="audio-player__details__description">
{description ?? ""}
</span>
</p>
)}
<p className="audio-player__details">
<span className="audio-player__details__label">Audio</span>
<span className="audio-player__details__caption">{caption ?? ""}</span>
</p>
</div>
);
}