fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
160 stars 14 forks source link

Incorrect permalinks #189

Open medienbaecker opened 6 months ago

medienbaecker commented 6 months ago

The markdown field inserts permalinks in a different structure compared to the textarea field:

CleanShot 2024-03-07 at 09 19 28@2x

This is a problem in the frontend, where page links are not correct:

CleanShot 2024-03-07 at 09 24 26@2x

It also does not help to run permalinksToUrls() on the field.

medienbaecker commented 6 months ago

FYI: because this issue is quite the big deal in a current project I've fixed it like this for now:

src/components/Buttons/Link.js

submit: (values) => {
    this.input.$panel.dialog.close();
    delete values.title;
    values.text = values.text || contents || null;
+       values.href = values.href.replace('/@/page/', 'page://');
    this.insertLink(values);
}

Of course a better solution would be to reuse the textarea dialog but I generally have no idea what I'm doing.

medienbaecker commented 4 months ago

After some time studying Kirby's code I think I know now why/how textarea and writer insert different links:

Maybe this helps someone in understanding the problem at hand. Or future-me at least.