Converting confluence-content to contentId

We have a static content macro, where we have the option to select an input of type “confluence-content” in the macro panel (
If the user selects a page e.g. outside of the current space for the input to the “confluence-content” input: How can we get the contentId of that page? “confluence-content” just returns a concatenation of the space key, a colon, and the page title. It is impossible to disambiguate the different inputs, because the page title might also contain a colon, and the space key might be missing if the page is in the current space.