diff --git a/client/modules/IDE/components/VersionPicker.jsx b/client/modules/IDE/components/VersionPicker.jsx index a42743d35..f048769dc 100644 --- a/client/modules/IDE/components/VersionPicker.jsx +++ b/client/modules/IDE/components/VersionPicker.jsx @@ -75,9 +75,23 @@ const VersionPicker = React.forwardRef(({ onChangeVersion }, ref) => { return ( - {versionInfo.version} + + {versionInfo + ? (() => { + const current = p5Versions.find((v) => + typeof v === 'string' + ? v === versionInfo.version + : v.version === versionInfo.version + ); + if (!current) return versionInfo.version; + if (typeof current === 'string') return current; + return `${current.version} ${current.label}`; + })() + : t('Toolbar.CustomLibraryVersion')} + @@ -86,11 +100,20 @@ const VersionPicker = React.forwardRef(({ onChangeVersion }, ref) => { align="left" maxHeight="50vh" > - {p5Versions.map((version) => ( - dispatchReplaceVersion(version)}> - {version} - - ))} + {p5Versions.map((item) => { + const version = typeof item === 'string' ? item : item.version; + const label = + typeof item === 'string' ? item : `${item.version} ${item.label}`; + + return ( + dispatchReplaceVersion(version)} + > + {label} + + ); + })} ); }); diff --git a/client/modules/IDE/hooks/useP5Version.jsx b/client/modules/IDE/hooks/useP5Version.jsx index 03ba3d0da..05dc96fe4 100644 --- a/client/modules/IDE/hooks/useP5Version.jsx +++ b/client/modules/IDE/hooks/useP5Version.jsx @@ -8,12 +8,12 @@ import PropTypes from 'prop-types'; // JSON.stringify([...document.querySelectorAll('._132722c7')].map(n => n.innerText), null, 2) // TODO: use their API for this to grab these at build time? export const p5Versions = [ - '2.0.3', + { version: '2.0.3', label: '(Beta)' }, '2.0.2', '2.0.1', '2.0.0', '1.11.8', - '1.11.7', + { version: '1.11.7', label: '(Default)' }, '1.11.6', '1.11.5', '1.11.4', @@ -197,7 +197,10 @@ export function P5VersionProvider(props) { if (!match) return null; // See if this is a version we recognize - if (p5Versions.includes(match[1])) { + const versionExists = p5Versions.some((v) => + typeof v === 'string' ? v === match[1] : v.version === match[1] + ); + if (versionExists) { return { version: match[1], minified: !!match[2], scriptNode }; } return null;