Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ In a PR that changes something users will notice, add a line under **Unreleased*

## Unreleased

### Fixed

- BetterMessageMenu shows the Delete icon instead of the word "trash".

## Build 159

### New
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/BetterMessageMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ConfigStore = { get(): MenuConfig; set(value: MenuConfig): void; use(): Men
const STORAGE_KEY = 'menu';

export default class BetterMessageMenu extends SlickPlugin<typeof meta.settings> implements EditorHost {
static readonly requiredAPIs = ['redux', 'menu'] as const;
static readonly requiredAPIs = ['redux', 'menu', 'elements'] as const;
static readonly id = meta.id;
static readonly pluginName = meta.pluginName;
static readonly description = meta.description;
Expand Down Expand Up @@ -195,7 +195,9 @@ export default class BetterMessageMenu extends SlickPlugin<typeof meta.settings>
const discovered = discoverActions(current, actions);
if (discovered !== current) this.update(discovered);
});
const next = applyMenu(actions, config, this.placement(props.targetBounds, height));
const next = applyMenu(actions, config, this.placement(props.targetBounds, height), (name) => (
<this.api.elements.SvgIcon name={name} size={20} />
));
const renderMenuItem = (args: any) => {
const rendered = props.renderMenuItem?.(args);
if (
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/BetterMessageMenu/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ function labelFor(id: string, descriptor: Descriptor, big: boolean, label?: stri
return descriptor.name;
}

export function applyMenu(groups: ActionGroups | undefined, config: MenuConfig, placement: Placement): ActionGroups {
export function applyMenu(
groups: ActionGroups | undefined,
config: MenuConfig,
placement: Placement,
renderIcon: (name: string) => unknown = (name) => name,
): ActionGroups {
if (!Array.isArray(groups)) return groups ?? [];
const flat = groups.flat().filter((action) => action && typeof action === 'object');
const cfg = new Map(config.order.map((item) => [item.id, item]));
Expand Down Expand Up @@ -71,7 +76,7 @@ export function applyMenu(groups: ActionGroups | undefined, config: MenuConfig,
const bigGroup = taken.map(({ id, action }, index) => ({
...action,
name: labelFor(id, action, true, cfg.get(id)?.label),
icon: action.icon ?? BIG_ICON[id],
icon: action.icon ?? (BIG_ICON[id] && renderIcon(BIG_ICON[id])),
className: [action.className, BIG_ACTION_CLASS, `${BIG_ACTION_CLASS}-n${counts[index]}`].filter(Boolean).join(' '),
}));
const main: Descriptor[] = [];
Expand Down
Loading