UNPKG

@znuny/ckeditor5-autocomplete-plugin

Version:

A plugin for CKEditor 5 that provides an extendable autocomplete functionality with predefined mention and HTML replacement logic.

72 lines (71 loc) 2.54 kB
/** * @copyright Copyright (c) 2024, Znuny GmbH. * @copyright Copyright (c) 2003-2024, CKSource Holding sp. z o.o. * * @license GNU GPL version 3 * * This software comes with ABSOLUTELY NO WARRANTY. For details, see * the enclosed file COPYING for license information (GPL). If you * did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt. */ import { type Editor } from 'ckeditor5/src/core.js'; import { Collection } from 'ckeditor5/src/utils.js'; import type { CompletionElement } from './Interfaces/CompletionElement'; import type { Marker } from 'ckeditor5/src/engine.js'; interface MentionsViewItem { item: CompletionElement; marker: string; confirmedSelectionHandler: () => void; } export declare class AutocompleteSelectionUi { static readonly defaultHandledKeyCodes: number[]; static readonly defaultCommitKeyCodes: number[]; availableMentionsViewItems: Collection<MentionsViewItem>; private readonly editor; private readonly pluginMarkerName; private readonly mentionsView; /** * The contextual balloon plugin instance. */ private balloon; constructor(editor: Editor, pluginMarkerName: string, commitKeyCodes?: Array<number>, overallSelectionDropdownLimit?: number); /** * Creates the {@link #mentionsView}. * @param overallSelectionDropdownLimit * @returns */ private createMentionView; /** * Renders a single item in the autocomplete list. */ private renderItem; /** * Shows the mentions balloon. If the panel is already visible, it will reposition it. */ showOrUpdateUI(markerMarker: Marker): void; /** * Hides the mentions balloon and removes the 'mention' marker from the markers collection. */ hideUIAndRemoveMarker(): void; /** * Creates a position options object used to position the balloon panel. * * @param mentionMarker * @param preferredPosition The name of the last matched position name. */ private getBalloonPanelPositionData; /** * Returns the balloon positions data callbacks. */ private getBalloonPanelPositions; /** * Checks the mention plugins is in completion mode (e.g. when typing is after a valid mention string like @foo). */ private isInCompletionMode; /** * Returns true when {@link #_mentionsView} is in the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon} and it is * currently visible. */ private isUIVisible; } export {};