question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A3: Custom icons do not appear in the context menu

See original GitHub issue

Hello, I noticed that setting/defining the icons in a custom module does not work nor when it is added it via the global list in modules/@apostrophecms/asset/lib/globalIcons.js

I am using the latest Apostrophe version 3.14.2.

module.exports = {
	extend: '@apostrophecms/widget-type',
	options: {
		label: 'Container',
		icon: 'plus-box'
	},
	icons: {
		'plus-box': 'PlusBox'
	}
}
Screenshot 2022-03-03 at 20 07 09

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
BoDonkeycommented, Oct 13, 2022

So, not a direct example like this using the rich-text-widget, but it is documented in two places.

For the init(self) it is in the reference section: https://v3.docs.apostrophecms.org/reference/module-api/module-overview.html

For the icon registration: https://v3.docs.apostrophecms.org/reference/module-api/module-options.html#icon

Not sure how to make it easier to navigate or another piece of documentation that would help. Any suggestions?

1reaction
BoDonkeycommented, Oct 13, 2022

Hi @waldemar-p, For visibility reasons, it is usually better to start a new issue, rather than making comments on a closed one.

Onto your problem! So I would make a few changes in your code. I don’t think you can extend the globalIcons.js in that way. Instead, register the icon right in your /modules/@apostrophecms/rich-text-widget/index.js file. After the options add:

icons: {
  'size-s-icon': 'SizeS'
}

Although your code seems to be working, I would also refactor your project-level rich-text-widget configuration. Remove the require and the editorTools section from the options. Instead, move them to an init() section:

module.exports = {
  init(self) {
    self.options.editorTools = {
      ...self.options.editorTools,
      slant: {
        component: 'AposTiptapButton',
        label: 'apostrophe:richTextStrikethrough',
        icon: 'size-s-icon',
        command: 'toggleStrike'
      }
    };
  },
  options: {
    ...
  },
  icons: {
    'size-s-icon': 'SizeS'
  }
};

Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Add And Remove Program Icons From Taskbar In ...
Right-click the taskbar and choose “Cortana", then Show Cortana icon ” from the pop-up menu. This tutorial will apply for computers, laptops, ...
Read more >
Context menu and icons not appearing version 160.4.4703
Hi,. I'm on Windows 10/Home; Dropbox version 160.4.4703 and all files are synched. However, no context menu and no icons. It's driving me...
Read more >
Working with the Element Context Menu - Paligo
You access the element context menu and guilabel is not shown in your favorites. This is because guilabel is not valid at the...
Read more >
Use icons—ArcGIS Dashboards | Documentation
The following are tips for creating a custom icon: For an indicator, if you don't define a stroke or fill in your SVG...
Read more >
Print in Microsoft Edge
Note that Immersive Reader may not be available for all websites. ... Right-click the selected text and then select Print in the context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found