Sitegeist.Archaeopteryx icon indicating copy to clipboard operation
Sitegeist.Archaeopteryx copied to clipboard

Hash link does not work

Open jonnitto opened this issue 2 years ago • 20 comments

If you have an link with an hash (e.g. #newsletter) the editor returns following error:

Could not find an editor suitable for "#newsletter"

And if I try to click + Create Link I got the error:

TypeError
can't access property "useResolvedModel", linkType is null

jonnitto avatar Sep 08 '21 07:09 jonnitto

@jonnitto We cannot reproduce this. Can you provide more informations

mficzel avatar May 05 '22 13:05 mficzel

First, it is not possible the set hashed links: CleanShot 2022-05-05 at 20 28 57@2x

Second, if you set a default value in the yaml file, you'll get this error

jonnitto avatar May 05 '22 18:05 jonnitto

Ahh now i got it ... you can workaround that by linking the current document with an anchor. Not exactly the same but close enough for now i assume.

mficzel avatar May 05 '22 19:05 mficzel

For me yes, for a customer not…

jonnitto avatar May 06 '22 19:05 jonnitto

We have the same issue here. We have some urls to pdf documents prepended with a hash. For example sth. like this: /_Resources/Persistent/2/8/3/4/28345d78a243cfe0b9e6c89709e996d3e2e3dad5/Bericht-xyz.pdf#page=7. These links come from the "old" link editor. As there is no anchor option for media files, this can also not be solved without additional workarounds (for example by adding an additional shortcut to the linked pdf). As the backend has an other domain than used later by frontend users, we can't prepend that uri with the domain and add the anchor there.

Benjamin-K avatar Mar 21 '23 16:03 Benjamin-K

For the issue pointed out by @jonnitto, i think this can simply be prevented by adding some checks before allowing the customer to save the link:

  • weblink must not start with a hash
  • weblink must start with a domain (some regex like ^([a-z0-9][a-z0-9-_]{0,61}[a-z0-9]?\.)+[a-z]{2,})

Benjamin-K avatar Mar 21 '23 16:03 Benjamin-K

As there is no anchor option for media files

but this is a matter of definition: https://github.com/sitegeist/Sitegeist.Archaeopteryx/blob/a003751455ccd6759cd6968dea11c08481ee4296/Neos.Ui/core/src/application/LinkTypes/Asset/Asset.tsx#L17 we could allow anchors on assets.

But this is rather a super edgecasy thing ...

About johns problem: Currently its not anticipated that the host is empty but the anchor is set. Instead of treating the href (protocol + host + path + anchor) as one unit, we allow the anchor to be specified as additional options. But this requires the protocol and host to be present.

mhsdesign avatar Oct 23 '23 06:10 mhsdesign

But this is rather a super edgecasy thing ...

It maybe is, but it is not disallowed to use anchors in assets and as you see above, there are valid cases where you might need them.

Example link: TransnetBW Nachhaltigkeitsbericht (Seite 6)

And as it might brake the editor if you switch from the "old" editor, i'd rather prefer adding it then having a bad editor experience, where a developer is needed to fix the link.

Benjamin-K avatar Oct 23 '23 10:10 Benjamin-K

Could this be solved using a custom link? https://github.com/sitegeist/Sitegeist.Archaeopteryx/pull/27

lorenzulrich avatar Dec 08 '23 10:12 lorenzulrich

The problem in our case is, that the Backend-Domain is different from the Frontend-Domain. Therefore we can't simply set a custom link, as we need to set the domain there and on the live-domain that target may not exist yet.

And: When switching from the "old" editor, i'd expect such links to still work and not show an error.

To solve the problem @jonnitto has, an editor should at least be able to add relative links. Then it should be possible to create links like /link/to/page or #newsletter or whatever is needed. I think in @jonnitto's case, all links that have the hash newsletter will open some subscription form or sth. That's a rare but still valid case...

Benjamin-K avatar Dec 08 '23 11:12 Benjamin-K

@Benjamin-K I see, now I get it. In the core LinkEditor, it is possible to add a hash to the node://abcd value.

This also means that the package wouldn't work with https://github.com/flownative/neos-anchorlinks.

To me, the most beautiful solution would be the ability to select any content node inside a selected page as link target. However, since Neos doesn't define the frontend output, this would only work if the id="foo" attribute is added to the container of each content node type - which is why this might not be such a good idea. Furthermore, I assume #newsletter in @jonnitto's case is a div that's not a content element, but somewhere in the footer.

So maybe a configurable (disabled by default) separate "anchor" field (or "link parameter") would be a good solution?

lorenzulrich avatar Dec 08 '23 13:12 lorenzulrich

Example: image

lorenzulrich avatar Dec 08 '23 13:12 lorenzulrich

@lorenzulrich Sry, you were right. The CustomLink will work for us, but it is a little complicated to enter the correct link. So i would still prefer adding a field Anchor for links that are set from the sidebar. In our case, some old links are currently broken in the backend (unable to edit them), because they were links like asset://<identifier>#hash, see screenshot: image

Benjamin-K avatar Dec 08 '23 15:12 Benjamin-K

@Benjamin-K I agree that this should be addressed if this package should go into the core - especially if it will work as drop-in replacement. But I think @mficzel would need to agree with a solution to the problem since it is Sitegeist's package.

lorenzulrich avatar Dec 08 '23 15:12 lorenzulrich

I think the custom link as defined here https://github.com/sitegeist/Sitegeist.Archaeopteryx/pull/27 is a good solution. Having yet another extra tab "Anchor" or similar will confuse as many editors as it will help.

mficzel avatar Dec 11 '23 15:12 mficzel

@mficzel I totally agree, that we should not add another new link editor to this package. The CustomLink solves the original issue described here. But the edge cases mentioned by @mhsdesign are still valid and will break the backend for some users in some places, of they use node or asset links with a hash in the sidebar. So yes, no new tab please! But this editor should keep links working that worked in the old editor. Shall we create a separate issue for this?

Benjamin-K avatar Dec 12 '23 05:12 Benjamin-K

@mficzel As you can see in my screenshot, it would not be an extra tab, but an extra property in the existing tag. This is just a suggestion. But maybe @Benjamin-K and we should open a new issue for this.

lorenzulrich avatar Dec 15 '23 21:12 lorenzulrich

There is also a new package in the wild: https://github.com/PaesslerAG/Paessler.Anchorlink

I think it would be nice to make Archaeopteryx extendable with own packages…

jonnitto avatar Feb 02 '24 14:02 jonnitto

@lorenzulrich @mficzel I have created a new issue https://github.com/sitegeist/Sitegeist.Archaeopteryx/issues/59 for the sub-problem mentioned here about existing links and a breaking editor, and a fix https://github.com/sitegeist/Sitegeist.Archaeopteryx/pull/60

rolandschuetz avatar Apr 10 '24 19:04 rolandschuetz