Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  setEnable only button
  • Loading branch information
jmuletpol committed Dec 1, 2024
2 parents a18cfcb + 6a21bc1 commit 5acd672
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion amd/build/commands.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/commands.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions amd/src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,25 @@ export const getSetup = async() => {
// Register the Icon.
editor.ui.registry.addIcon(icon, buttonImage.html);

// Disable button and menu item until the content has been set.
const onSetup = (api) => {
const cb = () => api.setEnabled(true);
editor.on('SetContent', cb);
return () => editor.off('SetContent', cb);
};

// Register the Toolbar Button.
editor.ui.registry.addButton(component, {
icon,
tooltip: pluginName,
onAction: () => handleAction(editor),
enabled: false,
onSetup
onSetup: (api) => {
const cb = () => api.setEnabled(true);
editor.on('SetContent', cb);
return () => editor.off('SetContent', cb);
}
});

// Add the Menu Item.
// This allows it to be added to a standard menu, or a context menu.
editor.ui.registry.addMenuItem(component, {
icon,
text: pluginName,
onAction: () => handleAction(editor),
enabled: false,
onSetup
onAction: () => handleAction(editor)
});
};
};

0 comments on commit 5acd672

Please sign in to comment.