UNPKG

4.33 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 list/todolist/todolistconverters
7 */
8import type { DowncastAttributeEvent, DowncastInsertEvent, Element, MapperModelToViewPositionEvent, Model, UpcastElementEvent, View } from 'ckeditor5/src/engine';
9import { type GetCallback } from 'ckeditor5/src/utils';
10/**
11 * A model-to-view converter for the `listItem` model element insertion.
12 *
13 * It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~UIElement checkbox element}
14 * at the beginning of each list item. It also merges the list with surrounding lists (if available).
15 *
16 * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
17 *
18 * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
19 * @param model Model instance.
20 * @param onCheckboxChecked Callback function.
21 * @returns Returns a conversion callback.
22 */
23export declare function modelViewInsertion(model: Model, onCheckboxChecked: (element: Element) => void): GetCallback<DowncastInsertEvent<Element>>;
24/**
25 * A model-to-view converter for the `listItem` model element insertion.
26 *
27 * It is used by {@link module:engine/controller/datacontroller~DataController}.
28 *
29 * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
30 * @param model Model instance.
31 * @returns Returns a conversion callback.
32 */
33export declare function dataModelViewInsertion(model: Model): GetCallback<DowncastInsertEvent<Element>>;
34/**
35 * A view-to-model converter for the checkbox element inside a view list item.
36 *
37 * It changes the `listType` of the model `listItem` to a `todo` value.
38 * When a view checkbox element is marked as checked, an additional `todoListChecked="true"` attribute is added to the model item.
39 *
40 * It is used by {@link module:engine/controller/datacontroller~DataController}.
41 *
42 * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
43 */
44export declare const dataViewModelCheckmarkInsertion: GetCallback<UpcastElementEvent>;
45/**
46 * A model-to-view converter for the `listType` attribute change on the `listItem` model element.
47 *
48 * This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
49 * {@link module:engine/view/uielement~UIElement checkbox UI element} is added at the beginning
50 * of the list item element (or vice versa).
51 *
52 * This converter is preceded by {@link module:list/list/converters~modelViewChangeType} and followed by
53 * {@link module:list/list/converters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists of the same type.
54 *
55 * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
56 *
57 * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
58 * @param onCheckedChange Callback fired after clicking the checkbox UI element.
59 * @param view Editing view controller.
60 * @returns Returns a conversion callback.
61 */
62export declare function modelViewChangeType(onCheckedChange: (element: Element) => void, view: View): GetCallback<DowncastAttributeEvent<Element>>;
63/**
64 * A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
65 *
66 * It marks the {@link module:engine/view/uielement~UIElement checkbox UI element} as checked.
67 *
68 * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
69 *
70 * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
71 * @param onCheckedChange Callback fired after clicking the checkbox UI element.
72 * @returns Returns a conversion callback.
73 */
74export declare function modelViewChangeChecked(onCheckedChange: (element: Element) => void): GetCallback<DowncastAttributeEvent<Element>>;
75/**
76 * A model-to-view position at zero offset mapper.
77 *
78 * This helper ensures that position inside todo-list in the view is mapped after the checkbox.
79 *
80 * It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
81 */
82export declare function mapModelToViewPosition(view: View): GetCallback<MapperModelToViewPositionEvent>;