SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
744 stars 389 forks source link

[decision needed] Fix links in CMS' HTML content #915

Closed Platonn closed 1 year ago

Platonn commented 5 years ago

CMS' HTML content may contain ordinary links (<a href>), but they may not work properly due to many reasons. For example, user is at /faq page and the CMS' HTML content contains links like: <a href="#anchor">. This causes prolems, as long as we have <base href="/">, because those links direct to /#anchor which is home page, not /faq#anchor.

Various cases should be also tested:

Ideally, we would like to avoid full reloads of page after clicking a relative link (in scope of SPA). Unfortunately a native <a href> is not the case.

We should investigate how to prepare links in CMS to work properly in Spartacus and/or think about some mechanism (pipe?) to fix those links before rendering with `[innerHTML] directive if necessary.

Related issues: FAQ https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/3482 T&C https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/3506

mirkosoft commented 5 years ago
mirkosoft commented 5 years ago

@Xymmer According to our talk the decision is about:

OR

Xymmer commented 5 years ago

we'll go with changing spa code so we handle our default sample data, but we won't go crazy trying to handle all kinds of html that could be added in the future

tobi-or-not-tobi commented 5 years ago

Just be aware of:

mirkosoft commented 5 years ago

Moving this back to TODO as I didn't have time to think about this more. Basically, long term solution (cms-driven approach) depends on CMSX-8545 (extend the current link component functionality to handle in-page jumps). The temporary solution is about either:

see https://github.com/angular/angular/blob/master/packages/core/src/sanitization/html_sanitizer.ts#L69

Xymmer commented 4 years ago

we'll have to schedule this one, talk to bill before taking this

AbdelhalimOuasti commented 3 years ago

Hi any news on this ? My customer needs FAQ page links.

Xymmer commented 3 years ago

@AbdelhalimOuasti since this is a sample data issue, you would normally have to customize the faq links. Is there something about this issue that is to be added generically to Spartacus itself?

AbdelhalimOuasti commented 3 years ago

Hi the problem is that the generated html does not keep the anchor :

- impex : <h2><a name=""l00""></a>Privacy and security</h2>
- HTML : <h2><a></a>Privacy and security</h2>
giancorderoortiz commented 3 years ago

Can this issue be solved in 4.0?

hackergil commented 3 years ago

Even after fixing the sample data, anchor names are not rendered (since DomSanitizer omits them)

A solution needs to be discussed for this one. Either we bypass DOM sanitization and trust HTML coming from the CMS or we come up with a more robust component. Ideas welcome.

Platonn commented 1 year ago

Local #anchor links in ParagraphComponent were fixed in https://github.com/SAP/spartacus/issues/14108

For other issues with ParagraphComponent, please create a new bug ticket, if needed.

Platonn commented 1 year ago

Duplicate of #14108