mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 09:52:36 +02:00
Make conversion menu searchable
This commit is contained in:
parent
65e30e90f7
commit
0f34f0fcc7
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
width: var(--width);
|
||||
height: unset;
|
||||
padding: 6px;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ce-popover__items {
|
||||
|
|
Loading…
Reference in a new issue