image
image copied to clipboard
access corresponding block from custom action
hi dear developers.
i want to create a custom action. in your first example i see somethings like this:
image: {
class: ImageTool,
config: {
actions: [
{
name: 'new_button',
icon: '<i class="fa fa-align-center"></i>',
title: 'title',
action: (name) => {
alert(`${name} `);
//access `corresponding` block ???
return false;
}
}
],
}
in this action you just used name and alert the name , i want to access block elements from this section and modify an image inside this block (and set width for image). how can i access block from this section? thanks
I found some solution by wrapping Image tool into my own class
export default class MyImageTool extends ImageTool {
constructor(props) {
super(props);
this.tunes.actions = this.tunes.actions.map((a) => {
return {
...a,
action: a.action.bind(this)
};
});
}
}
This helps to get this inside actions funcs