how to add a button in the toolbar for all components #5477
Unanswered
aliibrahim123
asked this question in
Q&A
Replies: 1 comment
-
This should work: editor.on("component:selected", (component: Component) => {
if (component.attributes.type === "wrapper") return; //avoid new toolbar button for wrapper component
const newTool = {
id: "save-component",
label: `${YOUR_SVG_LABEL}`,
title: "Title",
command: () => editor?.runCommand(YOUR_COMMAND),
};
const defaultToolbar = component.get("toolbar") as ToolbarButtonProps[];
const checkAlreadyExist = defaultToolbar.find((toolbar: ToolbarButtonProps) => toolbar.id === newTool.id);
if (!checkAlreadyExist) {
defaultToolbar.push({
id: newTool.id,
label: newTool.label,
command: newTool.command,
});
component.set("toolbar", defaultToolbar);
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
is there a way to add a button to the toolbar of all components
Beta Was this translation helpful? Give feedback.
All reactions