@ckeditor/ckeditor5-list 32.0.0 → 34.0.1
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/README.md +2 -1
- package/build/list.js +2 -2
- package/build/list.js.map +1 -0
- package/build/translations/cs.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/jv.js +1 -0
- package/build/translations/pt-br.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/ckeditor5-metadata.json +1 -1
- package/lang/translations/cs.po +4 -4
- package/lang/translations/de.po +4 -4
- package/lang/translations/el.po +27 -27
- package/lang/translations/en-au.po +4 -4
- package/lang/translations/es.po +22 -22
- package/lang/translations/gl.po +4 -4
- package/lang/translations/it.po +4 -4
- package/lang/translations/jv.po +125 -0
- package/lang/translations/pt-br.po +4 -4
- package/lang/translations/sk.po +4 -4
- package/lang/translations/sr-latn.po +4 -4
- package/lang/translations/sr.po +4 -4
- package/package.json +36 -24
- package/src/documentlist/converters.js +470 -0
- package/src/documentlist/documentlistcommand.js +216 -0
- package/src/documentlist/documentlistediting.js +676 -0
- package/src/documentlist/documentlistindentcommand.js +182 -0
- package/src/documentlist/documentlistmergecommand.js +235 -0
- package/src/documentlist/documentlistsplitcommand.js +114 -0
- package/src/documentlist/utils/listwalker.js +260 -0
- package/src/documentlist/utils/model.js +534 -0
- package/src/documentlist/utils/postfixers.js +138 -0
- package/src/documentlist/utils/view.js +148 -0
- package/src/documentlist.js +36 -0
- package/src/documentlistproperties/converters.js +57 -0
- package/src/documentlistproperties/documentlistpropertiesediting.js +338 -0
- package/src/documentlistproperties/documentlistreversedcommand.js +76 -0
- package/src/documentlistproperties/documentliststartcommand.js +76 -0
- package/src/documentlistproperties/documentliststylecommand.js +140 -0
- package/src/documentlistproperties/utils/style.js +41 -0
- package/src/documentlistproperties.js +37 -0
- package/src/index.js +10 -6
- package/src/{converters.js → list/converters.js} +11 -10
- package/src/{indentcommand.js → list/indentcommand.js} +1 -1
- package/src/{listcommand.js → list/listcommand.js} +1 -1
- package/src/{listediting.js → list/listediting.js} +11 -12
- package/src/{listui.js → list/listui.js} +3 -3
- package/src/{utils.js → list/utils.js} +35 -4
- package/src/list.js +7 -6
- package/src/{listpropertiesediting.js → listproperties/listpropertiesediting.js} +6 -5
- package/src/{listpropertiesui.js → listproperties/listpropertiesui.js} +15 -16
- package/src/{listreversedcommand.js → listproperties/listreversedcommand.js} +3 -3
- package/src/{liststartcommand.js → listproperties/liststartcommand.js} +3 -3
- package/src/{liststylecommand.js → listproperties/liststylecommand.js} +36 -4
- package/src/{ui → listproperties/ui}/collapsibleview.js +1 -1
- package/src/{ui → listproperties/ui}/listpropertiesview.js +1 -1
- package/src/listproperties.js +14 -9
- package/src/{checktodolistcommand.js → todolist/checktodolistcommand.js} +2 -2
- package/src/{todolistconverters.js → todolist/todolistconverters.js} +8 -4
- package/src/{todolistediting.js → todolist/todolistediting.js} +4 -4
- package/src/{todolistui.js → todolist/todolistui.js} +3 -3
- package/src/todolist.js +4 -4
- package/theme/documentlist.css +8 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/documentlistproperties/documentliststartcommand
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
|
11
|
+
import { first } from 'ckeditor5/src/utils';
|
|
12
|
+
import {
|
|
13
|
+
expandListBlocksToCompleteList,
|
|
14
|
+
isListItemBlock
|
|
15
|
+
} from '../documentlist/utils/model';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
19
|
+
* letting the user to choose the starting point of an ordered list.
|
|
20
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
21
|
+
*
|
|
22
|
+
* @extends module:core/command~Command
|
|
23
|
+
*/
|
|
24
|
+
export default class DocumentListStartCommand extends Command {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
refresh() {
|
|
29
|
+
const value = this._getValue();
|
|
30
|
+
|
|
31
|
+
this.value = value;
|
|
32
|
+
this.isEnabled = value != null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Executes the command.
|
|
37
|
+
*
|
|
38
|
+
* @fires execute
|
|
39
|
+
* @param {Object} [options]
|
|
40
|
+
* @param {Number} [options.startIndex=1] The list start index.
|
|
41
|
+
*/
|
|
42
|
+
execute( options = {} ) {
|
|
43
|
+
const model = this.editor.model;
|
|
44
|
+
const document = model.document;
|
|
45
|
+
|
|
46
|
+
let blocks = Array.from( document.selection.getSelectedBlocks() )
|
|
47
|
+
.filter( block => isListItemBlock( block ) && block.getAttribute( 'listType' ) == 'numbered' );
|
|
48
|
+
|
|
49
|
+
blocks = expandListBlocksToCompleteList( blocks );
|
|
50
|
+
|
|
51
|
+
model.change( writer => {
|
|
52
|
+
for ( const block of blocks ) {
|
|
53
|
+
writer.setAttribute( 'listStart', options.startIndex || 1, block );
|
|
54
|
+
}
|
|
55
|
+
} );
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Checks the command's {@link #value}.
|
|
60
|
+
*
|
|
61
|
+
* @private
|
|
62
|
+
* @returns {Number|null} The current value.
|
|
63
|
+
*/
|
|
64
|
+
_getValue() {
|
|
65
|
+
const model = this.editor.model;
|
|
66
|
+
const document = model.document;
|
|
67
|
+
|
|
68
|
+
const block = first( document.selection.getSelectedBlocks() );
|
|
69
|
+
|
|
70
|
+
if ( block && isListItemBlock( block ) && block.getAttribute( 'listType' ) == 'numbered' ) {
|
|
71
|
+
return block.getAttribute( 'listStart' );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/documentlistproperties/documentliststylecommand
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
|
11
|
+
import { first } from 'ckeditor5/src/utils';
|
|
12
|
+
import {
|
|
13
|
+
expandListBlocksToCompleteList,
|
|
14
|
+
isListItemBlock
|
|
15
|
+
} from '../documentlist/utils/model';
|
|
16
|
+
import { getListTypeFromListStyleType } from './utils/style';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
20
|
+
* letting the user choose styles for the list item markers.
|
|
21
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
22
|
+
*
|
|
23
|
+
* @extends module:core/command~Command
|
|
24
|
+
*/
|
|
25
|
+
export default class DocumentListStyleCommand extends Command {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of the command.
|
|
28
|
+
*
|
|
29
|
+
* @param {module:core/editor/editor~Editor} editor The editor instance.
|
|
30
|
+
* @param {String} defaultType The list type that will be used by default if the value was not specified during
|
|
31
|
+
* the command execution.
|
|
32
|
+
*/
|
|
33
|
+
constructor( editor, defaultType ) {
|
|
34
|
+
super( editor );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The default type of the list style.
|
|
38
|
+
*
|
|
39
|
+
* @protected
|
|
40
|
+
* @member {String}
|
|
41
|
+
*/
|
|
42
|
+
this._defaultType = defaultType;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
refresh() {
|
|
49
|
+
this.value = this._getValue();
|
|
50
|
+
this.isEnabled = this._checkEnabled();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Executes the command.
|
|
55
|
+
*
|
|
56
|
+
* @fires execute
|
|
57
|
+
* @param {Object} options
|
|
58
|
+
* @param {String|null} [options.type] The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
59
|
+
* style will be applied.
|
|
60
|
+
*/
|
|
61
|
+
execute( options = {} ) {
|
|
62
|
+
const model = this.editor.model;
|
|
63
|
+
const document = model.document;
|
|
64
|
+
|
|
65
|
+
model.change( writer => {
|
|
66
|
+
this._tryToConvertItemsToList( options );
|
|
67
|
+
|
|
68
|
+
let blocks = Array.from( document.selection.getSelectedBlocks() )
|
|
69
|
+
.filter( block => block.hasAttribute( 'listType' ) );
|
|
70
|
+
|
|
71
|
+
if ( !blocks.length ) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
blocks = expandListBlocksToCompleteList( blocks );
|
|
76
|
+
|
|
77
|
+
for ( const block of blocks ) {
|
|
78
|
+
writer.setAttribute( 'listStyle', options.type || this._defaultType, block );
|
|
79
|
+
}
|
|
80
|
+
} );
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Checks the command's {@link #value}.
|
|
85
|
+
*
|
|
86
|
+
* @private
|
|
87
|
+
* @returns {String|null} The current value.
|
|
88
|
+
*/
|
|
89
|
+
_getValue() {
|
|
90
|
+
const listItem = first( this.editor.model.document.selection.getSelectedBlocks() );
|
|
91
|
+
|
|
92
|
+
if ( isListItemBlock( listItem ) ) {
|
|
93
|
+
return listItem.getAttribute( 'listStyle' );
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Checks whether the command can be enabled in the current context.
|
|
101
|
+
*
|
|
102
|
+
* @private
|
|
103
|
+
* @returns {Boolean} Whether the command should be enabled.
|
|
104
|
+
*/
|
|
105
|
+
_checkEnabled() {
|
|
106
|
+
const editor = this.editor;
|
|
107
|
+
|
|
108
|
+
const numberedList = editor.commands.get( 'numberedList' );
|
|
109
|
+
const bulletedList = editor.commands.get( 'bulletedList' );
|
|
110
|
+
|
|
111
|
+
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
* @param {Object} options
|
|
119
|
+
* @param {String|null} [options.type] The type of the list style. If `null` is specified, the function does nothing.
|
|
120
|
+
*/
|
|
121
|
+
_tryToConvertItemsToList( options ) {
|
|
122
|
+
if ( !options.type ) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const listType = getListTypeFromListStyleType( options.type );
|
|
127
|
+
|
|
128
|
+
if ( !listType ) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const editor = this.editor;
|
|
133
|
+
const commandName = listType + 'List';
|
|
134
|
+
const command = editor.commands.get( commandName );
|
|
135
|
+
|
|
136
|
+
if ( !command.value ) {
|
|
137
|
+
editor.execute( commandName );
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/documentlistproperties/utils/style
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const BULLETED_LIST_STYLE_TYPES = [ 'disc', 'circle', 'square' ];
|
|
11
|
+
|
|
12
|
+
// There's a lot of them (https://www.w3.org/TR/css-counter-styles-3/#typedef-counter-style).
|
|
13
|
+
// Let's support only those that can be selected by ListPropertiesUI.
|
|
14
|
+
const NUMBERED_LIST_STYLE_TYPES = [
|
|
15
|
+
'decimal',
|
|
16
|
+
'decimal-leading-zero',
|
|
17
|
+
'lower-roman',
|
|
18
|
+
'upper-roman',
|
|
19
|
+
'lower-latin',
|
|
20
|
+
'upper-latin',
|
|
21
|
+
'lower-alpha',
|
|
22
|
+
'upper-alpha'
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
27
|
+
*
|
|
28
|
+
* @param {String} listStyleType
|
|
29
|
+
* @returns {'bulleted'|'numbered'|null}
|
|
30
|
+
*/
|
|
31
|
+
export function getListTypeFromListStyleType( listStyleType ) {
|
|
32
|
+
if ( BULLETED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
|
|
33
|
+
return 'bulleted';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ( NUMBERED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
|
|
37
|
+
return 'numbered';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/documentlistproperties
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import DocumentListPropertiesEditing from './documentlistproperties/documentlistpropertiesediting';
|
|
12
|
+
import ListPropertiesUI from './listproperties/listpropertiesui';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The document list properties feature.
|
|
16
|
+
*
|
|
17
|
+
* This is a "glue" plugin that loads the
|
|
18
|
+
* {@link module:list/documentlistproperties/documentlistpropertiesediting~DocumentListPropertiesEditing document list properties
|
|
19
|
+
* editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
20
|
+
*
|
|
21
|
+
* @extends module:core/plugin~Plugin
|
|
22
|
+
*/
|
|
23
|
+
export default class DocumentListProperties extends Plugin {
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires() {
|
|
28
|
+
return [ DocumentListPropertiesEditing, ListPropertiesUI ];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
static get pluginName() {
|
|
35
|
+
return 'DocumentListProperties';
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.js
CHANGED
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
* @module list
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
export { default as DocumentList } from './documentlist';
|
|
11
|
+
export { default as DocumentListEditing } from './documentlist/documentlistediting';
|
|
12
|
+
export { default as DocumentListProperties } from './documentlistproperties';
|
|
13
|
+
export { default as DocumentListPropertiesEditing } from './documentlistproperties/documentlistpropertiesediting';
|
|
10
14
|
export { default as List } from './list';
|
|
11
|
-
export { default as ListEditing } from './listediting';
|
|
12
|
-
export { default as ListUI } from './listui';
|
|
15
|
+
export { default as ListEditing } from './list/listediting';
|
|
16
|
+
export { default as ListUI } from './list/listui';
|
|
13
17
|
export { default as ListProperties } from './listproperties';
|
|
14
|
-
export { default as ListPropertiesEditing } from './listpropertiesediting';
|
|
15
|
-
export { default as ListPropertiesUI } from './listpropertiesui';
|
|
18
|
+
export { default as ListPropertiesEditing } from './listproperties/listpropertiesediting';
|
|
19
|
+
export { default as ListPropertiesUI } from './listproperties/listpropertiesui';
|
|
16
20
|
export { default as TodoList } from './todolist';
|
|
17
|
-
export { default as TodoListEditing } from './todolistediting';
|
|
18
|
-
export { default as TodoListUI } from './todolistui';
|
|
21
|
+
export { default as TodoListEditing } from './todolist/todolistediting';
|
|
22
|
+
export { default as TodoListUI } from './todolist/todolistui';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/converters
|
|
7
|
+
* @module list/list/converters
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { TreeWalker } from 'ckeditor5/src/engine';
|
|
@@ -97,11 +97,11 @@ export function modelViewRemove( model ) {
|
|
|
97
97
|
* A model-to-view converter for the `type` attribute change on the `listItem` model element.
|
|
98
98
|
*
|
|
99
99
|
* This change means that the `<li>` element parent changes from `<ul>` to `<ol>` (or vice versa). This is accomplished
|
|
100
|
-
* by breaking view elements and changing their name. The next {@link module:list/converters~modelViewMergeAfterChangeType}
|
|
100
|
+
* by breaking view elements and changing their name. The next {@link module:list/list/converters~modelViewMergeAfterChangeType}
|
|
101
101
|
* converter will attempt to merge split nodes.
|
|
102
102
|
*
|
|
103
103
|
* Splitting this conversion into 2 steps makes it possible to add an additional conversion in the middle.
|
|
104
|
-
* Check {@link module:list/todolistconverters~modelViewChangeType} to see an example of it.
|
|
104
|
+
* Check {@link module:list/todolist/todolistconverters~modelViewChangeType} to see an example of it.
|
|
105
105
|
*
|
|
106
106
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
107
107
|
* @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
|
|
@@ -109,7 +109,7 @@ export function modelViewRemove( model ) {
|
|
|
109
109
|
* @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
|
|
110
110
|
*/
|
|
111
111
|
export function modelViewChangeType( evt, data, conversionApi ) {
|
|
112
|
-
if ( !conversionApi.consumable.
|
|
112
|
+
if ( !conversionApi.consumable.test( data.item, evt.name ) ) {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -130,7 +130,7 @@ export function modelViewChangeType( evt, data, conversionApi ) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* A model-to-view converter that attempts to merge nodes split by {@link module:list/converters~modelViewChangeType}.
|
|
133
|
+
* A model-to-view converter that attempts to merge nodes split by {@link module:list/list/converters~modelViewChangeType}.
|
|
134
134
|
*
|
|
135
135
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
136
136
|
* @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
|
|
@@ -138,6 +138,8 @@ export function modelViewChangeType( evt, data, conversionApi ) {
|
|
|
138
138
|
* @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
|
|
139
139
|
*/
|
|
140
140
|
export function modelViewMergeAfterChangeType( evt, data, conversionApi ) {
|
|
141
|
+
conversionApi.consumable.consume( data.item, evt.name );
|
|
142
|
+
|
|
141
143
|
const viewItem = conversionApi.mapper.toViewElement( data.item );
|
|
142
144
|
const viewList = viewItem.parent;
|
|
143
145
|
const viewWriter = conversionApi.writer;
|
|
@@ -145,11 +147,6 @@ export function modelViewMergeAfterChangeType( evt, data, conversionApi ) {
|
|
|
145
147
|
// Merge the changed view list with other lists, if possible.
|
|
146
148
|
mergeViewLists( viewWriter, viewList, viewList.nextSibling );
|
|
147
149
|
mergeViewLists( viewWriter, viewList.previousSibling, viewList );
|
|
148
|
-
|
|
149
|
-
// Consumable insertion of children inside the item. They are already handled by re-building the item in view.
|
|
150
|
-
for ( const child of data.item.getChildren() ) {
|
|
151
|
-
conversionApi.consumable.consume( child, 'insert' );
|
|
152
|
-
}
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
/**
|
|
@@ -221,6 +218,10 @@ export function modelViewChangeIndent( model ) {
|
|
|
221
218
|
* @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
|
|
222
219
|
*/
|
|
223
220
|
export function modelViewSplitOnInsert( evt, data, conversionApi ) {
|
|
221
|
+
if ( !conversionApi.consumable.test( data.item, evt.name ) ) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
224
225
|
if ( data.item.name != 'listItem' ) {
|
|
225
226
|
let viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
|
|
226
227
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/listediting
|
|
7
|
+
* @module list/list/listediting
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import ListCommand from './listcommand';
|
|
@@ -171,19 +171,18 @@ export default class ListEditing extends Plugin {
|
|
|
171
171
|
evt.stop();
|
|
172
172
|
}, { context: 'li' } );
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
this.listenTo( editor.editing.view.document, 'tab', ( evt, data ) => {
|
|
175
|
+
const commandName = data.shiftKey ? 'outdentList' : 'indentList';
|
|
176
|
+
const command = this.editor.commands.get( commandName );
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
cancel();
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
};
|
|
178
|
+
if ( command.isEnabled ) {
|
|
179
|
+
editor.execute( commandName );
|
|
184
180
|
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
data.stopPropagation();
|
|
182
|
+
data.preventDefault();
|
|
183
|
+
evt.stop();
|
|
184
|
+
}
|
|
185
|
+
}, { context: 'li' } );
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
/**
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/listui
|
|
7
|
+
* @module list/list/listui
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { createUIComponent } from './utils';
|
|
11
11
|
|
|
12
|
-
import numberedListIcon from '
|
|
13
|
-
import bulletedListIcon from '
|
|
12
|
+
import numberedListIcon from '../../theme/icons/numberedlist.svg';
|
|
13
|
+
import bulletedListIcon from '../../theme/icons/bulletedlist.svg';
|
|
14
14
|
|
|
15
15
|
import { Plugin } from 'ckeditor5/src/core';
|
|
16
16
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/utils
|
|
7
|
+
* @module list/list/utils
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { TreeWalker, getFillerOffset } from 'ckeditor5/src/engine';
|
|
@@ -378,9 +378,9 @@ export function getSiblingNodes( position, direction ) {
|
|
|
378
378
|
/**
|
|
379
379
|
* Returns an array with all `listItem` elements in the model selection.
|
|
380
380
|
*
|
|
381
|
-
* It returns all the items even if only part of the list is selected, including items that belong to nested lists.
|
|
382
|
-
* If no list is selected, returns an empty array.
|
|
383
|
-
* The order of elements is not specified.
|
|
381
|
+
* It returns all the items even if only a part of the list is selected, including items that belong to nested lists.
|
|
382
|
+
* If no list is selected, it returns an empty array.
|
|
383
|
+
* The order of the elements is not specified.
|
|
384
384
|
*
|
|
385
385
|
* @protected
|
|
386
386
|
* @param {module:engine/model/model~Model} model
|
|
@@ -410,6 +410,37 @@ export function getSelectedListItems( model ) {
|
|
|
410
410
|
return listItems;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
const BULLETED_LIST_STYLE_TYPES = [ 'disc', 'circle', 'square' ];
|
|
414
|
+
|
|
415
|
+
// There's a lot of them (https://www.w3.org/TR/css-counter-styles-3/#typedef-counter-style).
|
|
416
|
+
// Let's support only those that can be selected by ListPropertiesUI.
|
|
417
|
+
const NUMBERED_LIST_STYLE_TYPES = [
|
|
418
|
+
'decimal',
|
|
419
|
+
'decimal-leading-zero',
|
|
420
|
+
'lower-roman',
|
|
421
|
+
'upper-roman',
|
|
422
|
+
'lower-latin',
|
|
423
|
+
'upper-latin'
|
|
424
|
+
];
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
428
|
+
*
|
|
429
|
+
* @param {String} listStyleType
|
|
430
|
+
* @returns {'bulleted'|'numbered'|null}
|
|
431
|
+
*/
|
|
432
|
+
export function getListTypeFromListStyleType( listStyleType ) {
|
|
433
|
+
if ( BULLETED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
|
|
434
|
+
return 'bulleted';
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if ( NUMBERED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
|
|
438
|
+
return 'numbered';
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
|
|
413
444
|
// Implementation of getFillerOffset for view list item element.
|
|
414
445
|
//
|
|
415
446
|
// @returns {Number|null} Block filler offset or `null` if block filler is not needed.
|
package/src/list.js
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
* @module list/list
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import ListEditing from './listediting';
|
|
11
|
-
import ListUI from './listui';
|
|
10
|
+
import ListEditing from './list/listediting';
|
|
11
|
+
import ListUI from './list/listui';
|
|
12
12
|
|
|
13
13
|
import { Plugin } from 'ckeditor5/src/core';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The list feature.
|
|
17
17
|
*
|
|
18
|
-
* This is a "glue" plugin that loads the {@link module:list/listediting~ListEditing list editing feature}
|
|
19
|
-
* and {@link module:list/listui~ListUI list UI feature}.
|
|
18
|
+
* This is a "glue" plugin that loads the {@link module:list/list/listediting~ListEditing list editing feature}
|
|
19
|
+
* and {@link module:list/list/listui~ListUI list UI feature}.
|
|
20
20
|
*
|
|
21
21
|
* @extends module:core/plugin~Plugin
|
|
22
22
|
*/
|
|
@@ -37,7 +37,8 @@ export default class List extends Plugin {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* The configuration of the {@link module:list/list~List list} feature
|
|
40
|
+
* The configuration of the {@link module:list/list~List list} feature
|
|
41
|
+
* and the {@link module:list/documentlist~DocumentList document list} feature.
|
|
41
42
|
*
|
|
42
43
|
* ClassicEditor
|
|
43
44
|
* .create( editorElement, {
|
|
@@ -52,7 +53,7 @@ export default class List extends Plugin {
|
|
|
52
53
|
*/
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
* The configuration of the {@link module:list/list~List} feature.
|
|
56
|
+
* The configuration of the {@link module:list/list~List} feature and the {@link module:list/documentlist~DocumentList} feature.
|
|
56
57
|
*
|
|
57
58
|
* Read more in {@link module:list/list~ListConfig}.
|
|
58
59
|
*
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/listpropertiesediting
|
|
7
|
+
* @module list/listproperties/listpropertiesediting
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import ListEditing from '
|
|
11
|
+
import ListEditing from '../list/listediting';
|
|
12
12
|
import ListStyleCommand from './liststylecommand';
|
|
13
13
|
import ListReversedCommand from './listreversedcommand';
|
|
14
14
|
import ListStartCommand from './liststartcommand';
|
|
15
|
-
import { getSiblingListItem, getSiblingNodes } from '
|
|
15
|
+
import { getSiblingListItem, getSiblingNodes } from '../list/utils';
|
|
16
16
|
|
|
17
17
|
const DEFAULT_LIST_TYPE = 'default';
|
|
18
18
|
|
|
@@ -133,7 +133,8 @@ export default class ListPropertiesEditing extends Plugin {
|
|
|
133
133
|
* See https://github.com/ckeditor/ckeditor5/issues/7879.
|
|
134
134
|
*
|
|
135
135
|
* @private
|
|
136
|
-
* @param {Array.<module:list/listpropertiesediting~AttributeStrategy>} attributeStrategies Strategies for the
|
|
136
|
+
* @param {Array.<module:list/listproperties/listpropertiesediting~AttributeStrategy>} attributeStrategies Strategies for the
|
|
137
|
+
* enabled attributes.
|
|
137
138
|
*/
|
|
138
139
|
_mergeListAttributesWhileMergingLists( attributeStrategies ) {
|
|
139
140
|
const editor = this.editor;
|
|
@@ -625,7 +626,7 @@ function fixListAttributesOnListItemElements( editor, attributeStrategies ) {
|
|
|
625
626
|
// ■ List item 1.
|
|
626
627
|
// ■ Paragraph[] // <-- The inserted item.
|
|
627
628
|
if ( !existingListItem || !existingListItem.is( 'element', 'listItem' ) ) {
|
|
628
|
-
existingListItem = insertedListItems[
|
|
629
|
+
existingListItem = insertedListItems[ 0 ].previousSibling;
|
|
629
630
|
|
|
630
631
|
if ( existingListItem ) {
|
|
631
632
|
const indent = insertedListItems[ 0 ].getAttribute( 'listIndent' );
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @module list/listpropertiesui
|
|
7
|
+
* @module list/listproperties/listpropertiesui
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
@@ -12,26 +12,26 @@ import { ButtonView, SplitButtonView, createDropdown } from 'ckeditor5/src/ui';
|
|
|
12
12
|
|
|
13
13
|
import ListPropertiesView from './ui/listpropertiesview';
|
|
14
14
|
|
|
15
|
-
import bulletedListIcon from '
|
|
16
|
-
import numberedListIcon from '
|
|
15
|
+
import bulletedListIcon from '../../theme/icons/bulletedlist.svg';
|
|
16
|
+
import numberedListIcon from '../../theme/icons/numberedlist.svg';
|
|
17
17
|
|
|
18
|
-
import listStyleDiscIcon from '
|
|
19
|
-
import listStyleCircleIcon from '
|
|
20
|
-
import listStyleSquareIcon from '
|
|
21
|
-
import listStyleDecimalIcon from '
|
|
22
|
-
import listStyleDecimalWithLeadingZeroIcon from '
|
|
23
|
-
import listStyleLowerRomanIcon from '
|
|
24
|
-
import listStyleUpperRomanIcon from '
|
|
25
|
-
import listStyleLowerLatinIcon from '
|
|
26
|
-
import listStyleUpperLatinIcon from '
|
|
18
|
+
import listStyleDiscIcon from '../../theme/icons/liststyledisc.svg';
|
|
19
|
+
import listStyleCircleIcon from '../../theme/icons/liststylecircle.svg';
|
|
20
|
+
import listStyleSquareIcon from '../../theme/icons/liststylesquare.svg';
|
|
21
|
+
import listStyleDecimalIcon from '../../theme/icons/liststyledecimal.svg';
|
|
22
|
+
import listStyleDecimalWithLeadingZeroIcon from '../../theme/icons/liststyledecimalleadingzero.svg';
|
|
23
|
+
import listStyleLowerRomanIcon from '../../theme/icons/liststylelowerroman.svg';
|
|
24
|
+
import listStyleUpperRomanIcon from '../../theme/icons/liststyleupperroman.svg';
|
|
25
|
+
import listStyleLowerLatinIcon from '../../theme/icons/liststylelowerlatin.svg';
|
|
26
|
+
import listStyleUpperLatinIcon from '../../theme/icons/liststyleupperlatin.svg';
|
|
27
27
|
|
|
28
|
-
import '
|
|
28
|
+
import '../../theme/liststyles.css';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
32
32
|
* buttons that allow users to control such aspects of list as the marker, start index or order.
|
|
33
33
|
*
|
|
34
|
-
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/listui~ListUI}
|
|
34
|
+
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
35
35
|
* (because they share the same names).
|
|
36
36
|
*
|
|
37
37
|
* @extends module:core/plugin~Plugin
|
|
@@ -228,10 +228,9 @@ function getStyleButtonCreator( { editor, listStyleCommand, parentCommandName }
|
|
|
228
228
|
editor.execute( 'listStyle', { type: listStyleCommand._defaultType } );
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
//
|
|
231
|
+
// Otherwise, leave the creation of the styled list to the `ListStyleCommand`.
|
|
232
232
|
else {
|
|
233
233
|
editor.model.change( () => {
|
|
234
|
-
editor.execute( parentCommandName );
|
|
235
234
|
editor.execute( 'listStyle', { type } );
|
|
236
235
|
} );
|
|
237
236
|
}
|