diff --git a/CHANGELOG.md b/CHANGELOG.md index b24da07..2fc9ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/plugins/BetterMessageMenu/index.tsx b/src/plugins/BetterMessageMenu/index.tsx index 69c5af6..b0ce0ce 100644 --- a/src/plugins/BetterMessageMenu/index.tsx +++ b/src/plugins/BetterMessageMenu/index.tsx @@ -25,7 +25,7 @@ type ConfigStore = { get(): MenuConfig; set(value: MenuConfig): void; use(): Men const STORAGE_KEY = 'menu'; export default class BetterMessageMenu extends SlickPlugin 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; @@ -195,7 +195,9 @@ export default class BetterMessageMenu extends SlickPlugin 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) => ( + + )); const renderMenuItem = (args: any) => { const rendered = props.renderMenuItem?.(args); if ( diff --git a/src/plugins/BetterMessageMenu/transform.ts b/src/plugins/BetterMessageMenu/transform.ts index 4277dac..0f33afc 100644 --- a/src/plugins/BetterMessageMenu/transform.ts +++ b/src/plugins/BetterMessageMenu/transform.ts @@ -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])); @@ -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[] = [];