Moreover, both Pierre Jeanjean and I think the proposed changes are not the right fix. If the input is space/document/attachments/image.png then you get 4 segments, where the space names are slice(0, 1) (the end index is not included). With the applied fix, the document name is included in the space names.
Pierre Jeanjean found this line that is related https://github.com/xwiki-contrib/cristal/blob/main/editors/blocknote-react/src/components/images/ImageSelector.tsx#L147 . It removes the document name from the displayed segments if the target document is not terminal, which is probably the default for Nextcloud references. The purpose of this IF is to avoid showing the technical "WebHome" page name, but this is specific to XWiki, so in the end we may need to have a back-end specific implementation for getting the list of reference segments to display.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.