UNPKG

2.74 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2024, 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 list/listproperties/listpropertiesediting
7 */
8import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9import type { Consumables, DowncastWriter, Element, Item, ViewElement } from 'ckeditor5/src/engine.js';
10import ListEditing, { type ListItemAttributesMap } from '../list/listediting.js';
11import ListPropertiesUtils from './listpropertiesutils.js';
12/**
13 * The document list properties engine feature.
14 *
15 * It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
16 * Read more in {@link module:list/listconfig~ListPropertiesConfig}.
17 */
18export default class ListPropertiesEditing extends Plugin {
19 /**
20 * @inheritDoc
21 */
22 static get requires(): readonly [typeof ListEditing, typeof ListPropertiesUtils];
23 /**
24 * @inheritDoc
25 */
26 static get pluginName(): "ListPropertiesEditing";
27 /**
28 * @inheritDoc
29 */
30 constructor(editor: Editor);
31 /**
32 * @inheritDoc
33 */
34 init(): void;
35}
36/**
37 * Strategy for dealing with `listItem` attributes supported by this plugin.
38 *
39 * @internal
40 */
41export interface AttributeStrategy {
42 /**
43 * The model attribute name.
44 */
45 attributeName: keyof ListItemAttributesMap;
46 /**
47 * The model attribute default value.
48 */
49 defaultValue: unknown;
50 /**
51 * The view consumable as expected by {@link module:engine/conversion/viewconsumable~ViewConsumable#consume `ViewConsumable`}.
52 */
53 viewConsumables: Consumables;
54 /**
55 * Registers an editor command.
56 */
57 addCommand(editor: Editor): void;
58 /**
59 * Verifies whether the strategy is applicable for the specified model element.
60 */
61 appliesToListItem(element: Item): boolean;
62 /**
63 * Verifies whether the model attribute value is valid.
64 */
65 hasValidAttribute(element: Element): boolean;
66 /**
67 * Sets the property on the view element.
68 */
69 setAttributeOnDowncast(writer: DowncastWriter, value: unknown, element: ViewElement): void;
70 /**
71 * Retrieves the property value from the view element.
72 */
73 getAttributeOnUpcast(element: ViewElement): unknown;
74}
75declare module '../list/listediting' {
76 interface ListItemAttributesMap {
77 listStyle?: string;
78 listStart?: number;
79 listReversed?: boolean;
80 }
81}
82declare module '../list/utils/model' {
83 interface ListElement {
84 getAttribute(key: 'listStyle'): string;
85 getAttribute(key: 'listStart'): number;
86 getAttribute(key: 'listReversed'): boolean;
87 }
88}