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/manualdecorator
|
7 | */
|
8 | import { type ArrayOrItem } from 'ckeditor5/src/utils';
|
9 | import type { MatcherObjectPattern } from 'ckeditor5/src/engine';
|
10 | import type { NormalizedLinkDecoratorManualDefinition } from '../utils';
|
11 | declare const ManualDecorator_base: {
|
12 | new (): import("ckeditor5/src/utils").Observable;
|
13 | prototype: import("ckeditor5/src/utils").Observable;
|
14 | };
|
15 | /**
|
16 | * Helper class that stores manual decorators with observable {@link module:link/utils/manualdecorator~ManualDecorator#value}
|
17 | * to support integration with the UI state. An instance of this class is a model with the state of individual manual decorators.
|
18 | * These decorators are kept as collections in {@link module:link/linkcommand~LinkCommand#manualDecorators}.
|
19 | */
|
20 | export default class ManualDecorator extends ManualDecorator_base {
|
21 | /**
|
22 | * An ID of a manual decorator which is the name of the attribute in the model, for example: 'linkManualDecorator0'.
|
23 | */
|
24 | id: string;
|
25 | /**
|
26 | * The value of the current manual decorator. It reflects its state from the UI.
|
27 | *
|
28 | * @observable
|
29 | */
|
30 | value: boolean | undefined;
|
31 | /**
|
32 | * The default value of manual decorator.
|
33 | */
|
34 | defaultValue?: boolean;
|
35 | /**
|
36 | * The label used in the user interface to toggle the manual decorator.
|
37 | */
|
38 | label: string;
|
39 | /**
|
40 | * A set of attributes added to downcasted data when the decorator is activated for a specific link.
|
41 | * Attributes should be added in a form of attributes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
|
42 | */
|
43 | attributes?: Record<string, string>;
|
44 | /**
|
45 | * A set of classes added to downcasted data when the decorator is activated for a specific link.
|
46 | * Classes should be added in a form of classes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
|
47 | */
|
48 | classes?: ArrayOrItem<string>;
|
49 | /**
|
50 | * A set of styles added to downcasted data when the decorator is activated for a specific link.
|
51 | * Styles should be added in a form of styles defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
|
52 | */
|
53 | styles?: Record<string, string>;
|
54 | /**
|
55 | * Creates a new instance of {@link module:link/utils/manualdecorator~ManualDecorator}.
|
56 | *
|
57 | * @param config.id The name of the attribute used in the model that represents a given manual decorator.
|
58 | * For example: `'linkIsExternal'`.
|
59 | * @param config.label The label used in the user interface to toggle the manual decorator.
|
60 | * @param config.attributes A set of attributes added to output data when the decorator is active for a specific link.
|
61 | * Attributes should keep the format of attributes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
|
62 | * @param [config.defaultValue] Controls whether the decorator is "on" by default.
|
63 | */
|
64 | constructor({ id, label, attributes, classes, styles, defaultValue }: NormalizedLinkDecoratorManualDefinition);
|
65 | /**
|
66 | * Returns {module:engine/view/matcher~MatcherPattern} with decorator attributes.
|
67 | *
|
68 | * @internal
|
69 | */
|
70 | _createPattern(): MatcherObjectPattern;
|
71 | }
|
72 | export {};
|