UNPKG

2.24 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module link/utils/automaticdecorators
7 */
8import { type ArrayOrItem } from 'ckeditor5/src/utils';
9import type { DowncastDispatcher } from 'ckeditor5/src/engine';
10import type { NormalizedLinkDecoratorAutomaticDefinition } from '../utils';
11/**
12 * Helper class that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition} and provides
13 * the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement downcast dispatchers} for them.
14 */
15export default class AutomaticDecorators {
16 /**
17 * Stores the definition of {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}.
18 * This data is used as a source for a downcast dispatcher to create a proper conversion to output data.
19 */
20 private _definitions;
21 /**
22 * Gives information about the number of decorators stored in the {@link module:link/utils/automaticdecorators~AutomaticDecorators}
23 * instance.
24 */
25 get length(): number;
26 /**
27 * Adds automatic decorator objects or an array with them to be used during downcasting.
28 *
29 * @param item A configuration object of automatic rules for decorating links. It might also be an array of such objects.
30 */
31 add(item: ArrayOrItem<NormalizedLinkDecoratorAutomaticDefinition>): void;
32 /**
33 * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method.
34 *
35 * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
36 */
37 getDispatcher(): (dispatcher: DowncastDispatcher) => void;
38 /**
39 * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method
40 * when linking images.
41 *
42 * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
43 */
44 getDispatcherForLinkedImage(): (dispatcher: DowncastDispatcher) => void;
45}