Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and use the registerIcon and useIcon utils #17755

Closed

Conversation

filipsobol
Copy link
Member

@filipsobol filipsobol commented Jan 15, 2025

Suggested merge commit message (convention)

Feature (core): Add a new icons configuration option to the editor. Related to #16546.

Feature (utils): Add registerIcon and useIcon helpers for registering and using customizable icons. Related to #16546.

Feature: Use registerIcon and useIcon helpers in all packages.


Additional information

This is a follow-up to #17750.

⚠️ TODO: Add docs explaining how to register, use, and override icons ⚠️

@filipsobol filipsobol changed the title Add icons repository Add and use the registerIcon and useIcon utils Jan 15, 2025
const POSSIBLE_INSERTION_POSITIONS = [ 'before', 'after' ] as const;

// Do the SVG parsing once and then clone the result <svg> DOM element for each new button.
const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString( IconReturnArrow, 'image/svg+xml' ).firstChild!;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much this change can affect performance?

@filipsobol filipsobol marked this pull request as ready for review January 15, 2025 14:26
Copy link
Contributor

@psmyrek psmyrek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

import { MenuBarMenuListItemButtonView, ButtonView } from 'ckeditor5/src/ui.js';
import { getButtonCreator } from '../utils.js';

const ITALIC = 'italic';
const italicIcon = /* #__PURE__ */ registerIcon( 'utalic', IconItalic );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const italicIcon = /* #__PURE__ */ registerIcon( 'utalic', IconItalic );
const italicIcon = /* #__PURE__ */ registerIcon( 'italic', IconItalic );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants