/**
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
 */

/**
 * @module list/list/listui
 */

import { createUIComponents } from './utils.js';
import { Plugin } from '@ckeditor/ckeditor5-core';
import { IconBulletedList, IconNumberedList } from '@ckeditor/ckeditor5-icons';

/**
 * The list UI feature. It introduces the `'numberedList'` and `'bulletedList'` buttons that
 * allow to convert paragraphs to and from list items and indent or outdent them.
 */
export class ListUI extends Plugin {
	/**
	 * @inheritDoc
	 */
	public static get pluginName() {
		return 'ListUI' as const;
	}

	/**
	 * @inheritDoc
	 */
	public static override get isOfficialPlugin(): true {
		return true;
	}

	/**
	 * @inheritDoc
	 */
	public init(): void {
		const t = this.editor.t;

		// Create button numberedList.
		if ( !this.editor.ui.componentFactory.has( 'numberedList' ) ) {
			createUIComponents( this.editor, 'numberedList', t( 'Numbered List' ), IconNumberedList );
		}

		// Create button bulletedList.
		if ( !this.editor.ui.componentFactory.has( 'bulletedList' ) ) {
			createUIComponents( this.editor, 'bulletedList', t( 'Bulleted List' ), IconBulletedList );
		}
	}
}
