@ckeditor/ckeditor5-list 36.0.0 → 37.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/list.js +1 -1
- package/package.json +39 -38
- package/src/documentlist/converters.d.ts +63 -0
- package/src/documentlist/converters.js +4 -4
- package/src/documentlist/documentlistcommand.d.ts +81 -0
- package/src/documentlist/documentlistcommand.js +1 -0
- package/src/documentlist/documentlistediting.d.ts +156 -0
- package/src/documentlist/documentlistindentcommand.d.ts +63 -0
- package/src/documentlist/documentlistindentcommand.js +1 -0
- package/src/documentlist/documentlistmergecommand.d.ts +77 -0
- package/src/documentlist/documentlistmergecommand.js +1 -0
- package/src/documentlist/documentlistsplitcommand.d.ts +68 -0
- package/src/documentlist/documentlistsplitcommand.js +1 -0
- package/src/documentlist/documentlistutils.d.ts +42 -0
- package/src/documentlist/utils/listwalker.d.ts +141 -0
- package/src/documentlist/utils/model.d.ts +193 -0
- package/src/documentlist/utils/postfixers.d.ts +37 -0
- package/src/documentlist/utils/view.d.ts +81 -0
- package/src/documentlist.d.ts +30 -0
- package/src/documentlist.js +1 -0
- package/src/documentlistproperties/converters.d.ts +19 -0
- package/src/documentlistproperties/documentlistpropertiesediting.d.ts +92 -0
- package/src/documentlistproperties/documentlistpropertiesutils.d.ts +38 -0
- package/src/documentlistproperties/documentlistreversedcommand.d.ts +37 -0
- package/src/documentlistproperties/documentlistreversedcommand.js +1 -0
- package/src/documentlistproperties/documentliststartcommand.d.ts +39 -0
- package/src/documentlistproperties/documentliststartcommand.js +1 -0
- package/src/documentlistproperties/documentliststylecommand.d.ts +73 -0
- package/src/documentlistproperties/documentliststylecommand.js +1 -0
- package/src/documentlistproperties/utils/style.d.ts +20 -0
- package/src/documentlistproperties.d.ts +31 -0
- package/src/documentlistproperties.js +1 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +2 -0
- package/src/list/converters.d.ts +196 -0
- package/src/list/converters.js +2 -2
- package/src/list/indentcommand.d.ts +39 -0
- package/src/list/indentcommand.js +1 -0
- package/src/list/listcommand.d.ts +56 -0
- package/src/list/listcommand.js +1 -0
- package/src/list/listediting.d.ts +34 -0
- package/src/list/listui.d.ts +24 -0
- package/src/list/listutils.d.ts +46 -0
- package/src/list/utils.d.ts +113 -0
- package/src/list/utils.js +2 -1
- package/src/list.d.ts +26 -0
- package/src/listcommands.d.ts +37 -0
- package/src/listconfig.d.ts +132 -0
- package/src/listproperties/listpropertiesediting.d.ts +76 -0
- package/src/listproperties/listpropertiesui.d.ts +29 -0
- package/src/listproperties/listpropertiesui.js +1 -0
- package/src/listproperties/listreversedcommand.d.ts +39 -0
- package/src/listproperties/listreversedcommand.js +1 -0
- package/src/listproperties/liststartcommand.d.ts +38 -0
- package/src/listproperties/liststartcommand.js +1 -0
- package/src/listproperties/liststylecommand.d.ts +68 -0
- package/src/listproperties/liststylecommand.js +2 -1
- package/src/listproperties/ui/collapsibleview.d.ts +63 -0
- package/src/listproperties/ui/listpropertiesview.d.ts +157 -0
- package/src/listproperties.d.ts +30 -0
- package/src/listproperties.js +1 -0
- package/src/liststyle.d.ts +32 -0
- package/src/todolist/checktodolistcommand.d.ts +53 -0
- package/src/todolist/checktodolistcommand.js +1 -0
- package/src/todolist/todolistconverters.d.ts +82 -0
- package/src/todolist/todolistediting.d.ts +43 -0
- package/src/todolist/todolistui.d.ts +24 -0
- package/src/todolist.d.ts +27 -0
|
@@ -0,0 +1,37 @@
|
|
|
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/documentlistproperties/documentlistreversedcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import '../listcommands';
|
|
10
|
+
/**
|
|
11
|
+
* The list reversed command. It changes the `listReversed` attribute of the selected list items,
|
|
12
|
+
* letting the user to choose the order of an ordered list.
|
|
13
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class DocumentListReversedCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
value: boolean | null;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
refresh(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Executes the command.
|
|
26
|
+
*
|
|
27
|
+
* @fires execute
|
|
28
|
+
* @param options.reversed Whether the list should be reversed.
|
|
29
|
+
*/
|
|
30
|
+
execute(options?: {
|
|
31
|
+
reversed?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks the command's {@link #value}.
|
|
35
|
+
*/
|
|
36
|
+
private _getValue;
|
|
37
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { Command } from 'ckeditor5/src/core';
|
|
9
9
|
import { first } from 'ckeditor5/src/utils';
|
|
10
10
|
import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
|
|
11
|
+
import '../listcommands';
|
|
11
12
|
/**
|
|
12
13
|
* The list reversed command. It changes the `listReversed` attribute of the selected list items,
|
|
13
14
|
* letting the user to choose the order of an ordered list.
|
|
@@ -0,0 +1,39 @@
|
|
|
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/documentlistproperties/documentliststartcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import '../listcommands';
|
|
10
|
+
/**
|
|
11
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
12
|
+
* letting the user to choose the starting point of an ordered list.
|
|
13
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class DocumentListStartCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
value: number | null;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
refresh(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Executes the command.
|
|
26
|
+
*
|
|
27
|
+
* @fires execute
|
|
28
|
+
* @param options.startIndex The list start index.
|
|
29
|
+
*/
|
|
30
|
+
execute({ startIndex }?: {
|
|
31
|
+
startIndex?: number;
|
|
32
|
+
}): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks the command's {@link #value}.
|
|
35
|
+
*
|
|
36
|
+
* @returns The current value.
|
|
37
|
+
*/
|
|
38
|
+
private _getValue;
|
|
39
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { Command } from 'ckeditor5/src/core';
|
|
9
9
|
import { first } from 'ckeditor5/src/utils';
|
|
10
10
|
import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
|
|
11
|
+
import '../listcommands';
|
|
11
12
|
/**
|
|
12
13
|
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
13
14
|
* letting the user to choose the starting point of an ordered list.
|
|
@@ -0,0 +1,73 @@
|
|
|
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/documentlistproperties/documentliststylecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
import '../listcommands';
|
|
10
|
+
/**
|
|
11
|
+
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
12
|
+
* letting the user choose styles for the list item markers.
|
|
13
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class DocumentListStyleCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
value: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* The default type of the list style.
|
|
22
|
+
*/
|
|
23
|
+
readonly defaultType: string;
|
|
24
|
+
/**
|
|
25
|
+
* The list of supported style types by this command.
|
|
26
|
+
*/
|
|
27
|
+
private _supportedTypes;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of the command.
|
|
30
|
+
*
|
|
31
|
+
* @param editor The editor instance.
|
|
32
|
+
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
33
|
+
* the command execution.
|
|
34
|
+
* @param supportedTypes The list of supported style types by this command.
|
|
35
|
+
*/
|
|
36
|
+
constructor(editor: Editor, defaultType: string, supportedTypes?: Array<string>);
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
refresh(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Executes the command.
|
|
43
|
+
*
|
|
44
|
+
* @fires execute
|
|
45
|
+
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
46
|
+
* style will be applied.
|
|
47
|
+
*/
|
|
48
|
+
execute(options?: {
|
|
49
|
+
type?: string | null;
|
|
50
|
+
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the given style type is supported by this plugin.
|
|
53
|
+
*/
|
|
54
|
+
isStyleTypeSupported(value: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Checks the command's {@link #value}.
|
|
57
|
+
*
|
|
58
|
+
* @returns The current value.
|
|
59
|
+
*/
|
|
60
|
+
private _getValue;
|
|
61
|
+
/**
|
|
62
|
+
* Checks whether the command can be enabled in the current context.
|
|
63
|
+
*
|
|
64
|
+
* @returns Whether the command should be enabled.
|
|
65
|
+
*/
|
|
66
|
+
private _checkEnabled;
|
|
67
|
+
/**
|
|
68
|
+
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
69
|
+
*
|
|
70
|
+
* @param options.type The type of the list style. If `null` is specified, the function does nothing.
|
|
71
|
+
*/
|
|
72
|
+
private _tryToConvertItemsToList;
|
|
73
|
+
}
|
|
@@ -9,6 +9,7 @@ import { Command } from 'ckeditor5/src/core';
|
|
|
9
9
|
import { first } from 'ckeditor5/src/utils';
|
|
10
10
|
import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
|
|
11
11
|
import { getListTypeFromListStyleType } from './utils/style';
|
|
12
|
+
import '../listcommands';
|
|
12
13
|
/**
|
|
13
14
|
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
14
15
|
* letting the user choose styles for the list item markers.
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
* Gets all the style types supported by given list type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAllSupportedStyleTypes(): Array<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getListTypeFromListStyleType(listStyleType: string): 'bulleted' | 'numbered' | null;
|
|
13
|
+
/**
|
|
14
|
+
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getListStyleTypeFromTypeAttribute(value: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getTypeAttributeFromListStyleType(value: string): string | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
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/documentlistproperties
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import './listconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The document list properties feature.
|
|
12
|
+
*
|
|
13
|
+
* This is a "glue" plugin that loads the
|
|
14
|
+
* {@link module:list/documentlistproperties/documentlistpropertiesediting~DocumentListPropertiesEditing document list properties
|
|
15
|
+
* editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
16
|
+
*/
|
|
17
|
+
export default class DocumentListProperties extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): PluginDependencies;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): 'DocumentListProperties';
|
|
26
|
+
}
|
|
27
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
28
|
+
interface PluginsMap {
|
|
29
|
+
[DocumentListProperties.pluginName]: DocumentListProperties;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
9
9
|
import DocumentListPropertiesEditing from './documentlistproperties/documentlistpropertiesediting';
|
|
10
10
|
import ListPropertiesUI from './listproperties/listpropertiesui';
|
|
11
|
+
import './listconfig';
|
|
11
12
|
/**
|
|
12
13
|
* The document list properties feature.
|
|
13
14
|
*
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
export { default as DocumentList } from './documentlist';
|
|
9
|
+
export { default as DocumentListEditing, type DocumentListEditingPostFixerEvent } from './documentlist/documentlistediting';
|
|
10
|
+
export { default as DocumentListIndentCommand } from './documentlist/documentlistindentcommand';
|
|
11
|
+
export { default as DocumentListProperties } from './documentlistproperties';
|
|
12
|
+
export { default as DocumentListPropertiesEditing } from './documentlistproperties/documentlistpropertiesediting';
|
|
13
|
+
export { default as DocumentListUtils } from './documentlist/documentlistutils';
|
|
14
|
+
export { default as DocumentListPropertiesUtils } from './documentlistproperties/documentlistpropertiesutils';
|
|
15
|
+
export { default as IndentCommand } from './list/indentcommand';
|
|
16
|
+
export { default as List } from './list';
|
|
17
|
+
export { default as ListEditing } from './list/listediting';
|
|
18
|
+
export { default as ListUI } from './list/listui';
|
|
19
|
+
export { default as ListProperties } from './listproperties';
|
|
20
|
+
export { default as ListUtils } from './list/listutils';
|
|
21
|
+
export { default as ListPropertiesEditing } from './listproperties/listpropertiesediting';
|
|
22
|
+
export { default as ListPropertiesUI } from './listproperties/listpropertiesui';
|
|
23
|
+
export { default as TodoList } from './todolist';
|
|
24
|
+
export { default as TodoListEditing } from './todolist/todolistediting';
|
|
25
|
+
export { default as TodoListUI } from './todolist/todolistui';
|
package/src/index.js
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { default as DocumentList } from './documentlist';
|
|
9
9
|
export { default as DocumentListEditing } from './documentlist/documentlistediting';
|
|
10
|
+
export { default as DocumentListIndentCommand } from './documentlist/documentlistindentcommand';
|
|
10
11
|
export { default as DocumentListProperties } from './documentlistproperties';
|
|
11
12
|
export { default as DocumentListPropertiesEditing } from './documentlistproperties/documentlistpropertiesediting';
|
|
12
13
|
export { default as DocumentListUtils } from './documentlist/documentlistutils';
|
|
13
14
|
export { default as DocumentListPropertiesUtils } from './documentlistproperties/documentlistpropertiesutils';
|
|
15
|
+
export { default as IndentCommand } from './list/indentcommand';
|
|
14
16
|
export { default as List } from './list';
|
|
15
17
|
export { default as ListEditing } from './list/listediting';
|
|
16
18
|
export { default as ListUI } from './list/listui';
|
|
@@ -0,0 +1,196 @@
|
|
|
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/list/converters
|
|
7
|
+
*/
|
|
8
|
+
import { type DowncastAttributeEvent, type DowncastInsertEvent, type DowncastRemoveEvent, type Element, type MapperModelToViewPositionEvent, type MapperViewToModelPositionEvent, type Model, type ModelInsertContentEvent, type UpcastElementEvent, type View, type Writer } from 'ckeditor5/src/engine';
|
|
9
|
+
import type { GetCallback } from 'ckeditor5/src/utils';
|
|
10
|
+
/**
|
|
11
|
+
* A model-to-view converter for the `listItem` model element insertion.
|
|
12
|
+
*
|
|
13
|
+
* It creates a `<ul><li></li><ul>` (or `<ol>`) view structure out of a `listItem` model element, inserts it at the correct
|
|
14
|
+
* position, and merges the list with surrounding lists (if available).
|
|
15
|
+
*
|
|
16
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
17
|
+
* @param model Model instance.
|
|
18
|
+
*/
|
|
19
|
+
export declare function modelViewInsertion(model: Model): GetCallback<DowncastInsertEvent<Element>>;
|
|
20
|
+
/**
|
|
21
|
+
* A model-to-view converter for the `listItem` model element removal.
|
|
22
|
+
*
|
|
23
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:remove
|
|
24
|
+
* @param model Model instance.
|
|
25
|
+
* @returns Returns a conversion callback.
|
|
26
|
+
*/
|
|
27
|
+
export declare function modelViewRemove(model: Model): GetCallback<DowncastRemoveEvent>;
|
|
28
|
+
/**
|
|
29
|
+
* A model-to-view converter for the `type` attribute change on the `listItem` model element.
|
|
30
|
+
*
|
|
31
|
+
* This change means that the `<li>` element parent changes from `<ul>` to `<ol>` (or vice versa). This is accomplished
|
|
32
|
+
* by breaking view elements and changing their name. The next {@link module:list/list/converters~modelViewMergeAfterChangeType}
|
|
33
|
+
* converter will attempt to merge split nodes.
|
|
34
|
+
*
|
|
35
|
+
* Splitting this conversion into 2 steps makes it possible to add an additional conversion in the middle.
|
|
36
|
+
* Check {@link module:list/todolist/todolistconverters~modelViewChangeType} to see an example of it.
|
|
37
|
+
*
|
|
38
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
39
|
+
*/
|
|
40
|
+
export declare const modelViewChangeType: GetCallback<DowncastAttributeEvent<Element>>;
|
|
41
|
+
/**
|
|
42
|
+
* A model-to-view converter that attempts to merge nodes split by {@link module:list/list/converters~modelViewChangeType}.
|
|
43
|
+
*
|
|
44
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
45
|
+
*/
|
|
46
|
+
export declare const modelViewMergeAfterChangeType: GetCallback<DowncastAttributeEvent<Element>>;
|
|
47
|
+
/**
|
|
48
|
+
* A model-to-view converter for the `listIndent` attribute change on the `listItem` model element.
|
|
49
|
+
*
|
|
50
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
51
|
+
* @param model Model instance.
|
|
52
|
+
* @returns Returns a conversion callback.
|
|
53
|
+
*/
|
|
54
|
+
export declare function modelViewChangeIndent(model: Model): GetCallback<DowncastAttributeEvent<Element>>;
|
|
55
|
+
/**
|
|
56
|
+
* A special model-to-view converter introduced by the {@link module:list/list~List list feature}. This converter is fired for
|
|
57
|
+
* insert change of every model item, and should be fired before the actual converter. The converter checks whether the inserted
|
|
58
|
+
* model item is a non-`listItem` element. If it is, and it is inserted inside a view list, the converter breaks the
|
|
59
|
+
* list so the model element is inserted to the view parent element corresponding to its model parent element.
|
|
60
|
+
*
|
|
61
|
+
* The converter prevents such situations:
|
|
62
|
+
*
|
|
63
|
+
* ```xml
|
|
64
|
+
* // Model: // View:
|
|
65
|
+
* <listItem>foo</listItem> <ul>
|
|
66
|
+
* <listItem>bar</listItem> <li>foo</li>
|
|
67
|
+
* <li>bar</li>
|
|
68
|
+
* </ul>
|
|
69
|
+
*
|
|
70
|
+
* // After change: // Correct view guaranteed by this converter:
|
|
71
|
+
* <listItem>foo</listItem> <ul><li>foo</li></ul><p>xxx</p><ul><li>bar</li></ul>
|
|
72
|
+
* <paragraph>xxx</paragraph> // Instead of this wrong view state:
|
|
73
|
+
* <listItem>bar</listItem> <ul><li>foo</li><p>xxx</p><li>bar</li></ul>
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
77
|
+
*/
|
|
78
|
+
export declare const modelViewSplitOnInsert: GetCallback<DowncastInsertEvent<Element>>;
|
|
79
|
+
/**
|
|
80
|
+
* A special model-to-view converter introduced by the {@link module:list/list~List list feature}. This converter takes care of
|
|
81
|
+
* merging view lists after something is removed or moved from near them.
|
|
82
|
+
*
|
|
83
|
+
* Example:
|
|
84
|
+
*
|
|
85
|
+
* ```xml
|
|
86
|
+
* // Model: // View:
|
|
87
|
+
* <listItem>foo</listItem> <ul><li>foo</li></ul>
|
|
88
|
+
* <paragraph>xxx</paragraph> <p>xxx</p>
|
|
89
|
+
* <listItem>bar</listItem> <ul><li>bar</li></ul>
|
|
90
|
+
*
|
|
91
|
+
* // After change: // Correct view guaranteed by this converter:
|
|
92
|
+
* <listItem>foo</listItem> <ul>
|
|
93
|
+
* <listItem>bar</listItem> <li>foo</li>
|
|
94
|
+
* <li>bar</li>
|
|
95
|
+
* </ul>
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:remove
|
|
99
|
+
*/
|
|
100
|
+
export declare const modelViewMergeAfter: GetCallback<DowncastRemoveEvent>;
|
|
101
|
+
/**
|
|
102
|
+
* A view-to-model converter that converts the `<li>` view elements into the `listItem` model elements.
|
|
103
|
+
*
|
|
104
|
+
* To set correct values of the `listType` and `listIndent` attributes the converter:
|
|
105
|
+
* * checks `<li>`'s parent,
|
|
106
|
+
* * stores and increases the `conversionApi.store.indent` value when `<li>`'s sub-items are converted.
|
|
107
|
+
*
|
|
108
|
+
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
109
|
+
*/
|
|
110
|
+
export declare const viewModelConverter: GetCallback<UpcastElementEvent>;
|
|
111
|
+
/**
|
|
112
|
+
* A view-to-model converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
|
|
113
|
+
* This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element, however, also
|
|
114
|
+
* incorrect data can be cleared if the view was incorrect.
|
|
115
|
+
*
|
|
116
|
+
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
117
|
+
*/
|
|
118
|
+
export declare const cleanList: GetCallback<UpcastElementEvent>;
|
|
119
|
+
/**
|
|
120
|
+
* A view-to-model converter for the `<li>` elements that cleans whitespace formatting from the input view.
|
|
121
|
+
*
|
|
122
|
+
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
123
|
+
*/
|
|
124
|
+
export declare const cleanListItem: GetCallback<UpcastElementEvent>;
|
|
125
|
+
/**
|
|
126
|
+
* Returns a callback for model position to view position mapping for {@link module:engine/conversion/mapper~Mapper}. The callback fixes
|
|
127
|
+
* positions between the `listItem` elements that would be incorrectly mapped because of how list items are represented in the model
|
|
128
|
+
* and in the view.
|
|
129
|
+
*/
|
|
130
|
+
export declare function modelToViewPosition(view: View): GetCallback<MapperModelToViewPositionEvent>;
|
|
131
|
+
/**
|
|
132
|
+
* The callback for view position to model position mapping for {@link module:engine/conversion/mapper~Mapper}. The callback fixes
|
|
133
|
+
* positions between the `<li>` elements that would be incorrectly mapped because of how list items are represented in the model
|
|
134
|
+
* and in the view.
|
|
135
|
+
*
|
|
136
|
+
* @see module:engine/conversion/mapper~Mapper#event:viewToModelPosition
|
|
137
|
+
* @param model Model instance.
|
|
138
|
+
* @returns Returns a conversion callback.
|
|
139
|
+
*/
|
|
140
|
+
export declare function viewToModelPosition(model: Model): GetCallback<MapperViewToModelPositionEvent>;
|
|
141
|
+
/**
|
|
142
|
+
* Post-fixer that reacts to changes on document and fixes incorrect model states.
|
|
143
|
+
*
|
|
144
|
+
* In the example below, there is a correct list structure.
|
|
145
|
+
* Then the middle element is removed so the list structure will become incorrect:
|
|
146
|
+
*
|
|
147
|
+
* ```xml
|
|
148
|
+
* <listItem listType="bulleted" listIndent=0>Item 1</listItem>
|
|
149
|
+
* <listItem listType="bulleted" listIndent=1>Item 2</listItem> <--- this is removed.
|
|
150
|
+
* <listItem listType="bulleted" listIndent=2>Item 3</listItem>
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* The list structure after the middle element is removed:
|
|
154
|
+
*
|
|
155
|
+
* ```xml
|
|
156
|
+
* <listItem listType="bulleted" listIndent=0>Item 1</listItem>
|
|
157
|
+
* <listItem listType="bulleted" listIndent=2>Item 3</listItem>
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* Should become:
|
|
161
|
+
*
|
|
162
|
+
* ```xml
|
|
163
|
+
* <listItem listType="bulleted" listIndent=0>Item 1</listItem>
|
|
164
|
+
* <listItem listType="bulleted" listIndent=1>Item 3</listItem> <--- note that indent got post-fixed.
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param model The data model.
|
|
168
|
+
* @param writer The writer to do changes with.
|
|
169
|
+
* @returns `true` if any change has been applied, `false` otherwise.
|
|
170
|
+
*/
|
|
171
|
+
export declare function modelChangePostFixer(model: Model, writer: Writer): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* A fixer for pasted content that includes list items.
|
|
174
|
+
*
|
|
175
|
+
* It fixes indentation of pasted list items so the pasted items match correctly to the context they are pasted into.
|
|
176
|
+
*
|
|
177
|
+
* Example:
|
|
178
|
+
*
|
|
179
|
+
* ```xml
|
|
180
|
+
* <listItem listType="bulleted" listIndent=0>A</listItem>
|
|
181
|
+
* <listItem listType="bulleted" listIndent=1>B^</listItem>
|
|
182
|
+
* // At ^ paste: <listItem listType="bulleted" listIndent=4>X</listItem>
|
|
183
|
+
* // <listItem listType="bulleted" listIndent=5>Y</listItem>
|
|
184
|
+
* <listItem listType="bulleted" listIndent=2>C</listItem>
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* Should become:
|
|
188
|
+
*
|
|
189
|
+
* ```xml
|
|
190
|
+
* <listItem listType="bulleted" listIndent=0>A</listItem>
|
|
191
|
+
* <listItem listType="bulleted" listIndent=1>BX</listItem>
|
|
192
|
+
* <listItem listType="bulleted" listIndent=2>Y/listItem>
|
|
193
|
+
* <listItem listType="bulleted" listIndent=2>C</listItem>
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export declare const modelIndentPasteFixer: GetCallback<ModelInsertContentEvent>;
|
package/src/list/converters.js
CHANGED
|
@@ -626,7 +626,7 @@ export function modelChangePostFixer(model, writer) {
|
|
|
626
626
|
* <listItem listType="bulleted" listIndent=2>C</listItem>
|
|
627
627
|
* ```
|
|
628
628
|
*/
|
|
629
|
-
export const modelIndentPasteFixer = function (evt, [content, selectable
|
|
629
|
+
export const modelIndentPasteFixer = function (evt, [content, selectable]) {
|
|
630
630
|
const model = this;
|
|
631
631
|
// Check whether inserted content starts from a `listItem`. If it does not, it means that there are some other
|
|
632
632
|
// elements before it and there is no need to fix indents, because even if we insert that content into a list,
|
|
@@ -639,7 +639,7 @@ export const modelIndentPasteFixer = function (evt, [content, selectable, placeO
|
|
|
639
639
|
selection = model.document.selection;
|
|
640
640
|
}
|
|
641
641
|
else {
|
|
642
|
-
selection = model.createSelection(selectable
|
|
642
|
+
selection = model.createSelection(selectable);
|
|
643
643
|
}
|
|
644
644
|
if (item && item.is('element', 'listItem')) {
|
|
645
645
|
// Get a reference list item. Inserted list items will be fixed according to that item.
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
6
|
+
import '../listcommands';
|
|
7
|
+
/**
|
|
8
|
+
* The list indent command. It is used by the {@link module:list/list~List list feature}.
|
|
9
|
+
*/
|
|
10
|
+
export default class IndentCommand extends Command {
|
|
11
|
+
/**
|
|
12
|
+
* Determines by how much the command will change the list item's indent attribute.
|
|
13
|
+
*/
|
|
14
|
+
private readonly _indentBy;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the command.
|
|
17
|
+
*
|
|
18
|
+
* @param editor The editor instance.
|
|
19
|
+
* @param indentDirection The direction of indent. If it is equal to `backward`, the command will outdent a list item.
|
|
20
|
+
*/
|
|
21
|
+
constructor(editor: Editor, indentDirection: 'forward' | 'backward');
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
|
|
28
|
+
*
|
|
29
|
+
* @fires execute
|
|
30
|
+
* @fires _executeCleanup
|
|
31
|
+
*/
|
|
32
|
+
execute(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks whether the command can be enabled in the current context.
|
|
35
|
+
*
|
|
36
|
+
* @returns Whether the command should be enabled.
|
|
37
|
+
*/
|
|
38
|
+
private _checkEnabled;
|
|
39
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
6
|
+
import '../listcommands';
|
|
7
|
+
/**
|
|
8
|
+
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
9
|
+
*/
|
|
10
|
+
export default class ListCommand extends Command {
|
|
11
|
+
/**
|
|
12
|
+
* The type of the list created by the command.
|
|
13
|
+
*/
|
|
14
|
+
readonly type: 'numbered' | 'bulleted' | 'todo';
|
|
15
|
+
/**
|
|
16
|
+
* A flag indicating whether the command is active, which means that the selection starts in a list of the same type.
|
|
17
|
+
*
|
|
18
|
+
* @readonly
|
|
19
|
+
*/
|
|
20
|
+
value: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of the command.
|
|
23
|
+
*
|
|
24
|
+
* @param editor The editor instance.
|
|
25
|
+
* @param type List type that will be handled by this command.
|
|
26
|
+
*/
|
|
27
|
+
constructor(editor: Editor, type: 'numbered' | 'bulleted' | 'todo');
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
refresh(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Executes the list command.
|
|
34
|
+
*
|
|
35
|
+
* @fires execute
|
|
36
|
+
* @param options Command options.
|
|
37
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
38
|
+
* selected items and potentially the neighbor elements to the proper list items. If set to `false`, it will convert selected elements
|
|
39
|
+
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
40
|
+
*/
|
|
41
|
+
execute(options?: {
|
|
42
|
+
forceValue?: boolean;
|
|
43
|
+
}): void;
|
|
44
|
+
/**
|
|
45
|
+
* Checks the command's {@link #value}.
|
|
46
|
+
*
|
|
47
|
+
* @returns The current value.
|
|
48
|
+
*/
|
|
49
|
+
private _getValue;
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether the command can be enabled in the current context.
|
|
52
|
+
*
|
|
53
|
+
* @returns Whether the command should be enabled.
|
|
54
|
+
*/
|
|
55
|
+
private _checkEnabled;
|
|
56
|
+
}
|
package/src/list/listcommand.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
6
|
+
import '../../theme/list.css';
|
|
7
|
+
/**
|
|
8
|
+
* The engine of the list feature. It handles creating, editing and removing lists and list items.
|
|
9
|
+
*
|
|
10
|
+
* It registers the `'numberedList'`, `'bulletedList'`, `'indentList'` and `'outdentList'` commands.
|
|
11
|
+
*/
|
|
12
|
+
export default class ListEditing extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get pluginName(): 'ListEditing';
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get requires(): PluginDependencies;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
init(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
afterInit(): void;
|
|
29
|
+
}
|
|
30
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
31
|
+
interface PluginsMap {
|
|
32
|
+
[ListEditing.pluginName]: ListEditing;
|
|
33
|
+
}
|
|
34
|
+
}
|