getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

[writer field] Allow opt-out of making relative links absolute when pasting HTML #4833

Closed igregson closed 1 year ago

igregson commented 1 year ago

Description

It should be possible to paste HTML into the writer field without it transforming relative links (href values) into absolute links.

This being the default and only behavior assumes that the panel's hostname is the same as the frontend's hostname. But this is not always the case, especially for headless Kirby.

Moreover, there are valid cases for wanting to preserve relative link URLs when pasting into the writer field.

Your setup

Kirby Version

3.8.1.1

afbora commented 1 year ago

Can you give a few examples of relative links you're having trouble with in your HTML code, please?

igregson commented 1 year ago

Can you give a few examples of relative links you're having trouble with in your HTML code, please?

Sure, here are a few examples:

<a href="/blog/recipes/homemade-ginger-ale-benefits-recipe">Read more</a>

<a href="/shop/product/manuka-honey/14136">Manuka honey</a>

<a href="/shop/product/ginger-root-powder-organic/8214">ginger root</a>

That's the source of the HTML. Copy and pasting that directly into the writer field simply pastes it as text (it doesn't parse it into actual markup). To reproduce the behavior I'm referring to above (where Kirby is rewriting relative URLs into absolute ones), copy and paste rendered markup from an HTML page that has relative links.

igregson commented 1 year ago

After looking into this further, it seems the issue is a browser behavior/bug rather than anything specific to Kirby.

Pretty surprised by this! I've shared my findings with details and screenshots to illustrate the issue here (https://stackoverflow.com/a/74360092/1971662).

Since this isn't Kirby-specific I'm going to close this. Sorry for the noise!