You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding links within the CKEditor field via the link dropdown to an internal existing entry page the hashtag appended to the URL persists when rendering in a front-end template.
Previously as an example in CKEditor v 3.8.1 this #entry: hashtag was stripped when rendering in a template.
Steps to reproduce
Highlight text in rich text field.
Click dropdown for link
Click link to entry
Select entry and confirm
Check link URL in CKEditor, confirm existence of #entry: hashtag
Save entry
Check template rendered with {{ entry.excerpt }}
Link/URL to the entry is correct though the #entry:77@1:url appended in the rich text field persists.
akukral
changed the title
Linking to Craft Entry appends persistent hashtag #entry:2@1:url
Linking to Craft Entry appends persistent hashtag #entry:77@1:url
Mar 21, 2024
Until this is addressed I'm using this javascript code to strip this out on the front end to some effect.
function rewriteLinks(stringToStrip) {
// Regular expression to match the string to strip with optional delimiters
const regex = new RegExp(`(?:/|\\?|&)?${stringToStrip}(?:/|\\?|&)?`, 'g');
const links = document.querySelectorAll('a');
for (const link of links) {
const href = link.href;
const newHref = href.replace(regex, '');
// Check if the URL changed to avoid unnecessary modifications
if (href !== newHref) {
link.href = newHref;
}
}
}
rewriteLinks('#entry:(.*?):url');
Description
When adding links within the CKEditor field via the link dropdown to an internal existing entry page the hashtag appended to the URL persists when rendering in a front-end template.
Previously as an example in CKEditor v 3.8.1 this #entry: hashtag was stripped when rendering in a template.
Steps to reproduce
Additional info
Local setup ddev version v1.22.7
Craft version: 5.0.0-beta.10
PHP version: 8.2.15
Database driver & version: MySQL 8.0.33
Plugins & versions:
CK Editor: 4.0.x-dev
Embedded Assets 5.0.0-beta.1
Freeform 5.1.4
Minify v5.x-dev
SEOmatic v5.x-dev
CK Editor Config
return { style: { definitions: [ { classes: [ 'brand-blue', ], element: 'span', name: 'Brand Blue', }, ], }, }
The text was updated successfully, but these errors were encountered: