You can look at https://forum.getkirby.com/t/howto-working-with-contextual-links-to-the-panel/1566/7 or the whole solution on that page. The pictures there are from the old Starterkit https://github.com/getkirby/starterkit/releases/tag/2.3.2!
May be, you have to adjust my code to your needs.
Good luck!