Closed (fixed)
Project:
Gutenberg
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Jun 2021 at 13:20 UTC
Updated:
22 Jan 2022 at 23:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kiss.jozsef commentedI did not find any good way of doing this , but on editing a media there was a custom submit added in the .module already so i added another ajax command which calls a function and in the function we call setAttributes which sets the same data again which causes a refresh so the image change or focal point change (or any other image related change) is shown in the editor on save.
Comment #3
szeidler commentedComment #4
codebymikey commentedThanks for putting in a working patch, I think the solution is sound, but in terms of future-proofing/best practices, I'd suggest not creating the jQuery function specifically in the component constructor, and creating a dedicated Ajax command and reacting to the change accordingly.
jQuery functions are more global and meant to be contextual in most cases.
The function name should also be namespaced (or more accurately prefixed) ideally with the
gutenbergname to avoid collision as well as make it easier to know which module it relates to.Example custom ajax command declaration in JS:
A sample ajax command may be generated using drupal-console's
drupal generate:ajax:commandcommand to help get started.I'd also suggest looking into implementing changes in issue forks as that makes it a lot easier to review and merge in changes.
Comment #5
kiss.jozsef commentedUpdated to ajaxcommands instead of jquery function.
Comment #9
szeidler commentedComment #11
marcofernandes commentedComment #12
sadeghbayan commentedThere is an issue with the provided patch. so when you update the alt text it will add an array inside array so it will be like: [['13056']] and when node is being saved the image will not be shown as its mediaEntityIds attribute is wrong.
I've added a helper function where we can call with the mediaEntityId so it will update/refresh the attributes.
Comment #13
esolitosComment #14
codebymikey commentedUntested, but the code looks good to me. An issue fork would be a much more manageable way of testing and getting it merged in.
One thing that's been on my mind for a while now is the usage of the
editor/...namespace for routes across the codebase.I believe all the routes should be prefixed with
gutenberg/just to avoid any potential collisions with the editor module's internal routing, it also makes it easier to associate the path to the Gutenberg module.The route stuff is pretty low priority at the moment, but an issue can be created to address it in the future.
Comment #17
marcofernandes commented