-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: adjust image editor to allow a custom upload screen component #3302
FEATURE: adjust image editor to allow a custom upload screen component #3302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx! Left some comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andrehoffmann30,
thanks for your PR :)
I was able to get it to work locally. But there's one small adjustment I'd like to suggest (see comment below).
On a larger note:
Adding this feature would change the behavior of the ImageEditor
, but would leave the behavior of the AssetEditor
intact. Imho the upload mechanism should not differ between the two, so it would be necessary to adjust the AssetEditor
as well.
// set media type constraint to "image/*" if it is not explicitly specified via options.constraints.mediaTypes | ||
const constraints = {...options.constraints, mediaTypes: (options.constraints && options.constraints.mediaTypes) || ['image/*']}; | ||
const {component: AssetUploadScreen} = secondaryEditorsRegistry.get('Neos.Neos/Inspector/Secondary/Editors/AssetUploadScreen'); | ||
this.props.renderSecondaryInspector('IMAGE_UPLOAD_MEDIA', () => <AssetUploadScreen type="images" constraints={constraints} onComplete={this.afterUpload}/>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to pass along propertyName
, focusedNodePath
, siteNodePath
and metadata
("Image" or "Asset") as well, so that all the information the uploadAsset
endpoint needs is available in the secondary inspector:
https://github.com/neos/neos-ui/blob/8.3/packages/neos-ui-backend-connector/src/Endpoints/index.ts#L224
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hallo @grebaldi , adjusted the asset editor to be able use the same custom upload dialog as the image editor. I have also adapted the code so that the additional data you mentioned is passed to the dialog. In the implementation of the dialog, you can then use the data accordingly if desired.
ecc6218
to
620d858
Compare
Hallo @mhsdesign I changed the merge goal to the 9.0 branch. Can you please adjust the labels accordingly? Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andrehoffmann30,
thanks a lot for your adjustments! I was able to test everything locally and it works perfectly 👌
620d858
to
232e779
Compare
What I did
I adjusted the image editor to allow a custom upload screen / dialog as an replacement option for the default upload behaviour.
How I did it
I adjusted the
handleChooseFile
function to look for aMediaUploadScreen
in the secondary editors registry. If a component is found , it is used and renderd as a secondary editor for the upload of a file. If no component is found, the previous behaviour is used for handeling the file upload.How to verify it
For testing this behaviour you need to write a plugin and add a component to be used as
MediaUploadScreen
to the secondary editors registry in your plugin.