How to trigger hook for admin panel?

System Information
  • Strapi Version: 4
  • Operating System: linux
  • Database: mariadb
  • Node Version: v16.13.1
  • NPM Version: 8.1.4
  • Yarn Version: 1.22.17

In Strapi v4 I have to models “Page” and “Version” with relation Page has many Versions. I created plugin with button “Add Version” (only for Page model) like this:

  const { modifiedData, layout } = useCMEditViewDataManager();

  return (
    <>
      {layout.apiID === 'page' && (
        <LinkButton
          to={`/content-manager/collectionType/api::version.version/create?pageId=${modifiedData.id}`}
          variant="success-light"
          startIcon={<PlusIcon />}
        >
          Add Version
        </LinkButton>
      )}
    </>
  );

btw. Is this a correct way how to do this?

Button works fine, and after I click on it, I am redirected to admin page “/api::version.version/create?pageId=3” as I wanted.

But I want to do two tasks inside form “Create an entry” for new version:

  1. I want to pre-fill relation Page with url parameter pageId=3
  2. I want to copy field “content” from previous version of pageId=3 (if exists) and pre-fill this content into new version of page, so user can modify last content.

Problem is how can I make hook for admin panel? In docs I found only hooks for api calls, but these calls are not triggered when admin panel edit or create form actions show.

Can anybody help me?