Merge branch 'update' into 'develop'

fix: 🐛 update model preview link in wysiwyg link plugin

See merge request ldc-web/projets/ldc!99
This commit is contained in:
karl.muller 2025-12-19 12:20:03 +00:00
commit bf792b463c
2 changed files with 13 additions and 2 deletions

View file

@ -24,6 +24,9 @@ interface GoToFrontViewProps {
/** Set visually in column */
isColumn?: boolean,
/** Add locale to the url */
addLocale?: boolean,
}
export default function GoToFrontView({
@ -32,6 +35,7 @@ export default function GoToFrontView({
additionalGroupPath = null,
isAvailable = false,
isColumn = false,
addLocale = true,
}: GoToFrontViewProps) {
const { locale, url } = usePage().props.appEnv as AppEnv;
@ -41,8 +45,10 @@ export default function GoToFrontView({
},
});
const cleanUrl = url.endsWith("/") ? url.slice(0, -1) : url;
const definitivePath = [
url + (locale === "fr" ? '' : '/' + locale),
cleanUrl + (addLocale ? (locale === "fr" ? '' : '/' + locale) : ''),
additionalGroupPath,
pathField,
]

View file

@ -496,9 +496,14 @@ export default function LinkButton({ editor, tooltip } : LinkProps) {
{selectedEntryUrl ? (
<GoToFrontView
modelName={str(selectedEnum?.label ?? '').lowerCase().value()}
pathField={selectedEntryUrl ? new URL(selectedEntryUrl).pathname.replace(/^\/+/, "") : ''}
pathField={selectedEntryUrl
? (selectedEntryUrl.startsWith("/")
? selectedEntryUrl.slice(1)
: selectedEntryUrl)
: ''}
isAvailable={true}
isColumn={true}
addLocale={false}
/>
) : (
<small className="text-start">{useTrans('back.wysiwyg_plugins.link.link')}</small>