Make conversion menu searchable

This commit is contained in:
Tanya Fomina 2024-05-01 00:07:17 +03:00
parent 65e30e90f7
commit 0f34f0fcc7
5 changed files with 21 additions and 8 deletions

View file

@ -503,6 +503,7 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
icon: IconReplace,
title: I18n.ui(I18nInternalNS.ui.popover, 'Convert to'),
children: {
searchable: true,
items: convertToItems,
},
});

View file

@ -149,18 +149,14 @@ export class PopoverItemDefault extends PopoverItem {
}
/**
* Returns list of item children
* Returns item children that are represented as popover items
*/
public get children(): PopoverItemParams[] {
// if (!('children' in this.params)) {
// return [];
// }
return 'children' in this.params && this.params.children?.items !== undefined ? this.params.children.items : [];
}
/**
* Returns list of item children
* Returns item children that are represented as custom HTML
*/
public get childrenHTML(): HTMLElement | undefined {
if (!('children' in this.params)) {
@ -171,12 +167,19 @@ export class PopoverItemDefault extends PopoverItem {
}
/**
*
* Returns true if item has any type of children
*/
public get hasChildren(): boolean {
return this.children.length > 0 || this.childrenHTML !== undefined;
}
/**
* Returns true if item has children that should be searchable
*/
public get isChildrenSearchable(): boolean {
return 'children' in this.params && this.params.children?.searchable === true;
}
/**
* Constructs HTML element corresponding to popover item params
*

View file

@ -143,7 +143,14 @@ export interface PopoverItemWithChildrenParams extends PopoverItemDefaultBasePar
* Items of nested popover that should be open on the current item hover/click (depending on platform)
*/
children?: {
items: PopoverItemParams[]
/**
* True if children items should be searchable
*/
searchable?: boolean;
items?: PopoverItemParams[];
customHtml?: HTMLElement;
}
}

View file

@ -355,6 +355,7 @@ export class PopoverDesktop extends PopoverAbstract {
*/
private showNestedPopoverForItem(item: PopoverItemDefault): void {
this.nestedPopover = new PopoverDesktop({
searchable: item.isChildrenSearchable,
customContent: item.childrenHTML,
items: item.children,
nestingLevel: this.nestingLevel + 1,

View file

@ -69,6 +69,7 @@
width: var(--width);
height: unset;
padding: 6px;
flex-direction: column;
}
.ce-popover__items {