@ckeditor/ckeditor5-list 34.0.0 → 34.2.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.
@@ -14,7 +14,7 @@ msgid ""
14
14
  msgstr ""
15
15
  "Language-Team: Portuguese (Brazil) (https://www.transifex.com/ckeditor/teams/11143/pt_BR/)\n"
16
16
  "Language: pt_BR\n"
17
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
17
+ "Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
18
18
 
19
19
  msgctxt "Toolbar button tooltip for the Numbered List feature."
20
20
  msgid "Numbered List"
@@ -14,7 +14,7 @@ msgid ""
14
14
  msgstr ""
15
15
  "Language-Team: Portuguese (https://www.transifex.com/ckeditor/teams/11143/pt/)\n"
16
16
  "Language: pt\n"
17
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
18
18
 
19
19
  msgctxt "Toolbar button tooltip for the Numbered List feature."
20
20
  msgid "Numbered List"
@@ -0,0 +1,125 @@
1
+ # Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Urdu (https://www.transifex.com/ckeditor/teams/11143/ur/)\n"
16
+ "Language: ur\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+
19
+ msgctxt "Toolbar button tooltip for the Numbered List feature."
20
+ msgid "Numbered List"
21
+ msgstr "ہندسی فہرست"
22
+
23
+ msgctxt "Toolbar button tooltip for the Bulleted List feature."
24
+ msgid "Bulleted List"
25
+ msgstr "غیر ہندسی فہرست"
26
+
27
+ msgctxt "Toolbar button tooltip for the To-do List feature."
28
+ msgid "To-do List"
29
+ msgstr ""
30
+
31
+ msgctxt "The ARIA label of the toolbar displaying buttons allowing users to change the bulleted list style."
32
+ msgid "Bulleted list styles toolbar"
33
+ msgstr ""
34
+
35
+ msgctxt "The ARIA label of the toolbar displaying buttons allowing users to change the numbered list style."
36
+ msgid "Numbered list styles toolbar"
37
+ msgstr ""
38
+
39
+ msgctxt "The ARIA label of the button that toggles the \"disc\" list style."
40
+ msgid "Toggle the disc list style"
41
+ msgstr ""
42
+
43
+ msgctxt "The ARIA label of the button that toggles the \"circle\" list style."
44
+ msgid "Toggle the circle list style"
45
+ msgstr ""
46
+
47
+ msgctxt "The ARIA label of the button that toggles the \"square\" list style."
48
+ msgid "Toggle the square list style"
49
+ msgstr ""
50
+
51
+ msgctxt "The ARIA label of the button that toggles the \"decimal\" list style."
52
+ msgid "Toggle the decimal list style"
53
+ msgstr ""
54
+
55
+ msgctxt "The ARIA label of the button that toggles the \"decimal with leading zero\" list style."
56
+ msgid "Toggle the decimal with leading zero list style"
57
+ msgstr ""
58
+
59
+ msgctxt "The ARIA label of the button that toggles the \"lower–roman\" list style."
60
+ msgid "Toggle the lower–roman list style"
61
+ msgstr ""
62
+
63
+ msgctxt "The ARIA label of the button that toggles the \"upper–roman\" list style."
64
+ msgid "Toggle the upper–roman list style"
65
+ msgstr ""
66
+
67
+ msgctxt "The ARIA label of the button that toggles the \"lower–latin\" list style."
68
+ msgid "Toggle the lower–latin list style"
69
+ msgstr ""
70
+
71
+ msgctxt "The ARIA label of the button that toggles the \"upper–latin\" list style."
72
+ msgid "Toggle the upper–latin list style"
73
+ msgstr ""
74
+
75
+ msgctxt "The tooltip text of the button that toggles the \"disc\" list style."
76
+ msgid "Disc"
77
+ msgstr ""
78
+
79
+ msgctxt "The tooltip text of the button that toggles the \"circle\" list style."
80
+ msgid "Circle"
81
+ msgstr ""
82
+
83
+ msgctxt "The tooltip text of the button that toggles the \"square\" list style."
84
+ msgid "Square"
85
+ msgstr ""
86
+
87
+ msgctxt "The tooltip text of the button that toggles the \"decimal\" list style."
88
+ msgid "Decimal"
89
+ msgstr ""
90
+
91
+ msgctxt "The tooltip text of the button that toggles the \"decimal with leading zero\" list style."
92
+ msgid "Decimal with leading zero"
93
+ msgstr ""
94
+
95
+ msgctxt "The tooltip text of the button that toggles the \"lower–roman\" list style."
96
+ msgid "Lower–roman"
97
+ msgstr ""
98
+
99
+ msgctxt "The tooltip text of the button that toggles the \"upper–roman\" list style."
100
+ msgid "Upper-roman"
101
+ msgstr ""
102
+
103
+ msgctxt "The tooltip text of the button that toggles the \"lower–latin\" list style."
104
+ msgid "Lower-latin"
105
+ msgstr ""
106
+
107
+ msgctxt "The tooltip text of the button that toggles the \"upper–latin\" list style."
108
+ msgid "Upper-latin"
109
+ msgstr ""
110
+
111
+ msgctxt "The label of the button that toggles the visibility of additional numbered list property UI fields."
112
+ msgid "List properties"
113
+ msgstr ""
114
+
115
+ msgctxt "The label of the input allowing to change the start index of a numbered list."
116
+ msgid "Start at"
117
+ msgstr ""
118
+
119
+ msgctxt "The error message displayed when the numbered list start index input value is invalid."
120
+ msgid "Start index must be greater than 0."
121
+ msgstr ""
122
+
123
+ msgctxt "The label of the switch button that reverses the order of the numbered list."
124
+ msgid "Reversed order"
125
+ msgstr ""
@@ -110,16 +110,16 @@ msgstr "大写拉丁字母"
110
110
 
111
111
  msgctxt "The label of the button that toggles the visibility of additional numbered list property UI fields."
112
112
  msgid "List properties"
113
- msgstr ""
113
+ msgstr "列表属性"
114
114
 
115
115
  msgctxt "The label of the input allowing to change the start index of a numbered list."
116
116
  msgid "Start at"
117
- msgstr ""
117
+ msgstr "起始编号"
118
118
 
119
119
  msgctxt "The error message displayed when the numbered list start index input value is invalid."
120
120
  msgid "Start index must be greater than 0."
121
- msgstr ""
121
+ msgstr "起始编号必须大于0。"
122
122
 
123
123
  msgctxt "The label of the switch button that reverses the order of the numbered list."
124
124
  msgid "Reversed order"
125
- msgstr ""
125
+ msgstr "顺序反转"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-list",
3
- "version": "34.0.0",
3
+ "version": "34.2.0",
4
4
  "description": "Ordered and unordered lists feature to CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,43 +12,44 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^34.0.0",
16
- "@ckeditor/ckeditor5-ui": "^34.0.0"
15
+ "ckeditor5": "^34.2.0",
16
+ "@ckeditor/ckeditor5-ui": "^34.2.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@ckeditor/ckeditor5-alignment": "^34.0.0",
20
- "@ckeditor/ckeditor5-basic-styles": "^34.0.0",
21
- "@ckeditor/ckeditor5-block-quote": "^34.0.0",
22
- "@ckeditor/ckeditor5-clipboard": "^34.0.0",
23
- "@ckeditor/ckeditor5-cloud-services": "^34.0.0",
24
- "@ckeditor/ckeditor5-code-block": "^34.0.0",
25
- "@ckeditor/ckeditor5-core": "^34.0.0",
19
+ "@ckeditor/ckeditor5-alignment": "^34.2.0",
20
+ "@ckeditor/ckeditor5-autoformat": "^34.2.0",
21
+ "@ckeditor/ckeditor5-basic-styles": "^34.2.0",
22
+ "@ckeditor/ckeditor5-block-quote": "^34.2.0",
23
+ "@ckeditor/ckeditor5-clipboard": "^34.2.0",
24
+ "@ckeditor/ckeditor5-cloud-services": "^34.2.0",
25
+ "@ckeditor/ckeditor5-code-block": "^34.2.0",
26
+ "@ckeditor/ckeditor5-core": "^34.2.0",
26
27
  "@ckeditor/ckeditor5-dev-utils": "^30.0.0",
27
- "@ckeditor/ckeditor5-easy-image": "^34.0.0",
28
- "@ckeditor/ckeditor5-editor-classic": "^34.0.0",
29
- "@ckeditor/ckeditor5-engine": "^34.0.0",
30
- "@ckeditor/ckeditor5-enter": "^34.0.0",
31
- "@ckeditor/ckeditor5-essentials": "^34.0.0",
32
- "@ckeditor/ckeditor5-font": "^34.0.0",
33
- "@ckeditor/ckeditor5-heading": "^34.0.0",
34
- "@ckeditor/ckeditor5-highlight": "^34.0.0",
35
- "@ckeditor/ckeditor5-horizontal-line": "^34.0.0",
36
- "@ckeditor/ckeditor5-html-embed": "^34.0.0",
37
- "@ckeditor/ckeditor5-html-support": "^34.0.0",
38
- "@ckeditor/ckeditor5-image": "^34.0.0",
39
- "@ckeditor/ckeditor5-indent": "^34.0.0",
40
- "@ckeditor/ckeditor5-link": "^34.0.0",
41
- "@ckeditor/ckeditor5-media-embed": "^34.0.0",
42
- "@ckeditor/ckeditor5-page-break": "^34.0.0",
43
- "@ckeditor/ckeditor5-paragraph": "^34.0.0",
44
- "@ckeditor/ckeditor5-remove-format": "^34.0.0",
45
- "@ckeditor/ckeditor5-source-editing": "^34.0.0",
46
- "@ckeditor/ckeditor5-table": "^34.0.0",
47
- "@ckeditor/ckeditor5-theme-lark": "^34.0.0",
48
- "@ckeditor/ckeditor5-typing": "^34.0.0",
49
- "@ckeditor/ckeditor5-undo": "^34.0.0",
50
- "@ckeditor/ckeditor5-utils": "^34.0.0",
51
- "@ckeditor/ckeditor5-widget": "^34.0.0",
28
+ "@ckeditor/ckeditor5-easy-image": "^34.2.0",
29
+ "@ckeditor/ckeditor5-editor-classic": "^34.2.0",
30
+ "@ckeditor/ckeditor5-engine": "^34.2.0",
31
+ "@ckeditor/ckeditor5-enter": "^34.2.0",
32
+ "@ckeditor/ckeditor5-essentials": "^34.2.0",
33
+ "@ckeditor/ckeditor5-font": "^34.2.0",
34
+ "@ckeditor/ckeditor5-heading": "^34.2.0",
35
+ "@ckeditor/ckeditor5-highlight": "^34.2.0",
36
+ "@ckeditor/ckeditor5-horizontal-line": "^34.2.0",
37
+ "@ckeditor/ckeditor5-html-embed": "^34.2.0",
38
+ "@ckeditor/ckeditor5-html-support": "^34.2.0",
39
+ "@ckeditor/ckeditor5-image": "^34.2.0",
40
+ "@ckeditor/ckeditor5-indent": "^34.2.0",
41
+ "@ckeditor/ckeditor5-link": "^34.2.0",
42
+ "@ckeditor/ckeditor5-media-embed": "^34.2.0",
43
+ "@ckeditor/ckeditor5-page-break": "^34.2.0",
44
+ "@ckeditor/ckeditor5-paragraph": "^34.2.0",
45
+ "@ckeditor/ckeditor5-remove-format": "^34.2.0",
46
+ "@ckeditor/ckeditor5-source-editing": "^34.2.0",
47
+ "@ckeditor/ckeditor5-table": "^34.2.0",
48
+ "@ckeditor/ckeditor5-theme-lark": "^34.2.0",
49
+ "@ckeditor/ckeditor5-typing": "^34.2.0",
50
+ "@ckeditor/ckeditor5-undo": "^34.2.0",
51
+ "@ckeditor/ckeditor5-utils": "^34.2.0",
52
+ "@ckeditor/ckeditor5-widget": "^34.2.0",
52
53
  "webpack": "^5.58.1",
53
54
  "webpack-cli": "^4.9.0"
54
55
  },
@@ -34,7 +34,8 @@ import {
34
34
  isLastBlockOfListItem,
35
35
  isSingleListItem,
36
36
  getSelectedBlockObject,
37
- isListItemBlock
37
+ isListItemBlock,
38
+ removeListAttributes
38
39
  } from './utils/model';
39
40
  import {
40
41
  getViewElementIdForListType,
@@ -116,8 +117,6 @@ export default class DocumentListEditing extends Plugin {
116
117
  } );
117
118
  }
118
119
 
119
- model.on( 'insertContent', createModelIndentPasteFixer( model ), { priority: 'high' } );
120
-
121
120
  // Register commands.
122
121
  editor.commands.add( 'numberedList', new DocumentListCommand( editor, 'numbered' ) );
123
122
  editor.commands.add( 'bulletedList', new DocumentListCommand( editor, 'bulleted' ) );
@@ -134,6 +133,7 @@ export default class DocumentListEditing extends Plugin {
134
133
  this._setupDeleteIntegration();
135
134
  this._setupEnterIntegration();
136
135
  this._setupTabIntegration();
136
+ this._setupClipboardIntegration();
137
137
  }
138
138
 
139
139
  /**
@@ -455,6 +455,54 @@ export default class DocumentListEditing extends Plugin {
455
455
  evt.return = fixListItemIds( listNodes, seenIds, writer ) || evt.return;
456
456
  }, { priority: 'high' } );
457
457
  }
458
+
459
+ /**
460
+ * Integrates the feature with the clipboard via {@link module:engine/model/model~Model#insertContent} and
461
+ * {@link module:engine/model/model~Model#getSelectedContent}.
462
+ *
463
+ * @private
464
+ */
465
+ _setupClipboardIntegration() {
466
+ const model = this.editor.model;
467
+
468
+ this.listenTo( model, 'insertContent', createModelIndentPasteFixer( model ), { priority: 'high' } );
469
+
470
+ // To enhance the UX, the editor should not copy list attributes to the clipboard if the selection
471
+ // started and ended in the same list item.
472
+ //
473
+ // If the selection was enclosed in a single list item, there is a good chance the user did not want it
474
+ // copied as a list item but plain blocks.
475
+ //
476
+ // This avoids pasting orphaned list items instead of paragraphs, for instance, straight into the root.
477
+ //
478
+ // ┌─────────────────────┬───────────────────┐
479
+ // │ Selection │ Clipboard content │
480
+ // ├─────────────────────┼───────────────────┤
481
+ // │ [* <Widget />] │ <Widget /> │
482
+ // ├─────────────────────┼───────────────────┤
483
+ // │ [* Foo] │ Foo │
484
+ // ├─────────────────────┼───────────────────┤
485
+ // │ * Foo [bar] baz │ bar │
486
+ // ├─────────────────────┼───────────────────┤
487
+ // │ * Fo[o │ o │
488
+ // │ ba]r │ ba │
489
+ // ├─────────────────────┼───────────────────┤
490
+ // │ * Fo[o │ * o │
491
+ // │ * ba]r │ * ba │
492
+ // ├─────────────────────┼───────────────────┤
493
+ // │ [* Foo │ * Foo │
494
+ // │ * bar] │ * bar │
495
+ // └─────────────────────┴───────────────────┘
496
+ //
497
+ // See https://github.com/ckeditor/ckeditor5/issues/11608.
498
+ this.listenTo( model, 'getSelectedContent', ( evt, [ selection ] ) => {
499
+ const isSingleListItemSelected = isSingleListItem( Array.from( selection.getSelectedBlocks() ) );
500
+
501
+ if ( isSingleListItemSelected ) {
502
+ model.change( writer => removeListAttributes( Array.from( evt.return.getChildren() ), writer ) );
503
+ }
504
+ } );
505
+ }
458
506
  }
459
507
 
460
508
  /**
@@ -14,7 +14,12 @@ import DocumentListStartCommand from './documentliststartcommand';
14
14
  import DocumentListStyleCommand from './documentliststylecommand';
15
15
  import DocumentListReversedCommand from './documentlistreversedcommand';
16
16
  import { listPropertiesUpcastConverter } from './converters';
17
- import { getListTypeFromListStyleType } from './utils/style';
17
+ import {
18
+ getAllSupportedStyleTypes,
19
+ getListTypeFromListStyleType,
20
+ getListStyleTypeFromTypeAttribute,
21
+ getTypeAttributeFromListStyleType
22
+ } from './utils/style';
18
23
 
19
24
  const DEFAULT_LIST_TYPE = 'default';
20
25
 
@@ -221,7 +226,8 @@ export default class DocumentListPropertiesEditing extends Plugin {
221
226
  // Creates an array of strategies for dealing with enabled listItem attributes.
222
227
  //
223
228
  // @param {Object} enabledProperties
224
- // @param {Boolean} enabledProperties.styles
229
+ // @param {Boolean|Object} enabledProperties.styles
230
+ // @param {Boolean} [enabledProperties.styles.useAttribute]
225
231
  // @param {Boolean} enabledProperties.reversed
226
232
  // @param {Boolean} enabledProperties.startIndex
227
233
  // @returns {Array.<module:list/documentlistproperties/documentlistpropertiesediting~AttributeStrategy>}
@@ -229,13 +235,21 @@ function createAttributeStrategies( enabledProperties ) {
229
235
  const strategies = [];
230
236
 
231
237
  if ( enabledProperties.styles ) {
238
+ const useAttribute = typeof enabledProperties.styles == 'object' && enabledProperties.styles.useAttribute;
239
+
232
240
  strategies.push( {
233
241
  attributeName: 'listStyle',
234
242
  defaultValue: DEFAULT_LIST_TYPE,
235
243
  viewConsumables: { styles: 'list-style-type' },
236
244
 
237
245
  addCommand( editor ) {
238
- editor.commands.add( 'listStyle', new DocumentListStyleCommand( editor, DEFAULT_LIST_TYPE ) );
246
+ let supportedTypes = getAllSupportedStyleTypes();
247
+
248
+ if ( useAttribute ) {
249
+ supportedTypes = supportedTypes.filter( styleType => !!getTypeAttributeFromListStyleType( styleType ) );
250
+ }
251
+
252
+ editor.commands.add( 'listStyle', new DocumentListStyleCommand( editor, DEFAULT_LIST_TYPE, supportedTypes ) );
239
253
  },
240
254
 
241
255
  appliesToListItem() {
@@ -258,14 +272,39 @@ function createAttributeStrategies( enabledProperties ) {
258
272
 
259
273
  setAttributeOnDowncast( writer, listStyle, element ) {
260
274
  if ( listStyle && listStyle !== DEFAULT_LIST_TYPE ) {
261
- writer.setStyle( 'list-style-type', listStyle, element );
262
- } else {
263
- writer.removeStyle( 'list-style-type', element );
275
+ if ( useAttribute ) {
276
+ const value = getTypeAttributeFromListStyleType( listStyle );
277
+
278
+ if ( value ) {
279
+ writer.setAttribute( 'type', value, element );
280
+
281
+ return;
282
+ }
283
+ } else {
284
+ writer.setStyle( 'list-style-type', listStyle, element );
285
+
286
+ return;
287
+ }
264
288
  }
289
+
290
+ writer.removeStyle( 'list-style-type', element );
291
+ writer.removeAttribute( 'type', element );
265
292
  },
266
293
 
267
294
  getAttributeOnUpcast( listParent ) {
268
- return listParent.getStyle( 'list-style-type' ) || DEFAULT_LIST_TYPE;
295
+ const style = listParent.getStyle( 'list-style-type' );
296
+
297
+ if ( style ) {
298
+ return style;
299
+ }
300
+
301
+ const attribute = listParent.getAttribute( 'type' );
302
+
303
+ if ( attribute ) {
304
+ return getListStyleTypeFromTypeAttribute( attribute );
305
+ }
306
+
307
+ return DEFAULT_LIST_TYPE;
269
308
  }
270
309
  } );
271
310
  }
@@ -29,8 +29,9 @@ export default class DocumentListStyleCommand extends Command {
29
29
  * @param {module:core/editor/editor~Editor} editor The editor instance.
30
30
  * @param {String} defaultType The list type that will be used by default if the value was not specified during
31
31
  * the command execution.
32
+ * @param {Array.<String>} [supportedTypes] The list of supported style types by this command.
32
33
  */
33
- constructor( editor, defaultType ) {
34
+ constructor( editor, defaultType, supportedTypes ) {
34
35
  super( editor );
35
36
 
36
37
  /**
@@ -40,6 +41,14 @@ export default class DocumentListStyleCommand extends Command {
40
41
  * @member {String}
41
42
  */
42
43
  this._defaultType = defaultType;
44
+
45
+ /**
46
+ * The list of supported style types by this command.
47
+ *
48
+ * @private
49
+ * @member {Array.<String>|undefined}
50
+ */
51
+ this._supportedTypes = supportedTypes;
43
52
  }
44
53
 
45
54
  /**
@@ -80,6 +89,20 @@ export default class DocumentListStyleCommand extends Command {
80
89
  } );
81
90
  }
82
91
 
92
+ /**
93
+ * Checks if the given style type is supported by this plugin.
94
+ *
95
+ * @param {String} value
96
+ * @returns {Boolean}
97
+ */
98
+ isStyleTypeSupported( value ) {
99
+ if ( !this._supportedTypes ) {
100
+ return true;
101
+ }
102
+
103
+ return this._supportedTypes.includes( value );
104
+ }
105
+
83
106
  /**
84
107
  * Checks the command's {@link #value}.
85
108
  *
@@ -7,21 +7,42 @@
7
7
  * @module list/documentlistproperties/utils/style
8
8
  */
9
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'
10
+ const LIST_STYLE_TO_LIST_TYPE = {};
11
+ const LIST_STYLE_TO_TYPE_ATTRIBUTE = {};
12
+ const TYPE_ATTRIBUTE_TO_LIST_STYLE = {};
13
+
14
+ const LIST_STYLE_TYPES = [
15
+ { listStyle: 'disc', typeAttribute: 'disc', listType: 'bulleted' },
16
+ { listStyle: 'circle', typeAttribute: 'circle', listType: 'bulleted' },
17
+ { listStyle: 'square', typeAttribute: 'square', listType: 'bulleted' },
18
+ { listStyle: 'decimal', typeAttribute: '1', listType: 'numbered' },
19
+ { listStyle: 'decimal-leading-zero', typeAttribute: null, listType: 'numbered' },
20
+ { listStyle: 'lower-roman', typeAttribute: 'i', listType: 'numbered' },
21
+ { listStyle: 'upper-roman', typeAttribute: 'I', listType: 'numbered' },
22
+ { listStyle: 'lower-alpha', typeAttribute: 'a', listType: 'numbered' },
23
+ { listStyle: 'upper-alpha', typeAttribute: 'A', listType: 'numbered' },
24
+ { listStyle: 'lower-latin', typeAttribute: 'a', listType: 'numbered' },
25
+ { listStyle: 'upper-latin', typeAttribute: 'A', listType: 'numbered' }
23
26
  ];
24
27
 
28
+ for ( const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES ) {
29
+ LIST_STYLE_TO_LIST_TYPE[ listStyle ] = listType;
30
+ LIST_STYLE_TO_TYPE_ATTRIBUTE[ listStyle ] = typeAttribute;
31
+
32
+ if ( typeAttribute ) {
33
+ TYPE_ATTRIBUTE_TO_LIST_STYLE[ typeAttribute ] = listStyle;
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Gets all the style types supported by given list type.
39
+ *
40
+ * @returns {Array.<String>}
41
+ */
42
+ export function getAllSupportedStyleTypes() {
43
+ return LIST_STYLE_TYPES.map( x => x.listStyle );
44
+ }
45
+
25
46
  /**
26
47
  * Checks whether the given list-style-type is supported by numbered or bulleted list.
27
48
  *
@@ -29,13 +50,25 @@ const NUMBERED_LIST_STYLE_TYPES = [
29
50
  * @returns {'bulleted'|'numbered'|null}
30
51
  */
31
52
  export function getListTypeFromListStyleType( listStyleType ) {
32
- if ( BULLETED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
33
- return 'bulleted';
34
- }
53
+ return LIST_STYLE_TO_LIST_TYPE[ listStyleType ] || null;
54
+ }
35
55
 
36
- if ( NUMBERED_LIST_STYLE_TYPES.includes( listStyleType ) ) {
37
- return 'numbered';
38
- }
56
+ /**
57
+ * Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
58
+ *
59
+ * @param {String} value
60
+ * @returns {String|null}
61
+ */
62
+ export function getListStyleTypeFromTypeAttribute( value ) {
63
+ return TYPE_ATTRIBUTE_TO_LIST_STYLE[ value ] || null;
64
+ }
39
65
 
40
- return null;
66
+ /**
67
+ * Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
68
+ *
69
+ * @param {String} value
70
+ * @returns {String|null}
71
+ */
72
+ export function getTypeAttributeFromListStyleType( value ) {
73
+ return LIST_STYLE_TO_TYPE_ATTRIBUTE[ value ] || null;
41
74
  }
package/src/index.js CHANGED
@@ -7,6 +7,10 @@
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
15
  export { default as ListEditing } from './list/listediting';
12
16
  export { default as ListUI } from './list/listui';
@@ -277,7 +277,12 @@ function createListPropertiesView( {
277
277
  listStyleCommand
278
278
  } );
279
279
 
280
- styleButtonViews = styleDefinitions.map( styleButtonCreator );
280
+ // The command can be ListStyleCommand or DocumentListStyleCommand.
281
+ const isStyleTypeSupported = typeof listStyleCommand.isStyleTypeSupported == 'function' ?
282
+ styleDefinition => listStyleCommand.isStyleTypeSupported( styleDefinition.type ) :
283
+ () => true;
284
+
285
+ styleButtonViews = styleDefinitions.filter( isStyleTypeSupported ).map( styleButtonCreator );
281
286
  }
282
287
 
283
288
  const listPropertiesView = new ListPropertiesView( locale, {
@@ -65,10 +65,14 @@ export default class ListProperties extends Plugin {
65
65
  */
66
66
 
67
67
  /**
68
- * When set, the list style feature will be enabled. It allows changing the `list-style-type` HTML attribute of the lists.
68
+ * When set, the list style feature will be enabled. It allows changing the `list-style-type` style or the `type` HTML attribute of a list.
69
+ *
70
+ * **Note**: Styling using the `type` HTML attribute is only available in
71
+ * {@link module:list/documentlistproperties~DocumentListProperties document list properties}
72
+ * ({@link module:list/listproperties~ListPropertiesStyleConfig learn more}).
69
73
  *
70
74
  * @default true
71
- * @member {Boolean} module:list/listproperties~ListPropertiesConfig#styles
75
+ * @member {Boolean|module:list/listproperties~ListPropertiesStyleConfig} module:list/listproperties~ListPropertiesConfig#styles
72
76
  */
73
77
 
74
78
  /**
@@ -99,3 +103,33 @@ export default class ListProperties extends Plugin {
99
103
  *
100
104
  * @member {module:list/listproperties~ListPropertiesConfig} module:list/list~ListConfig#properties
101
105
  */
106
+
107
+ /**
108
+ * @interface ListPropertiesStyleConfig
109
+ */
110
+
111
+ /**
112
+ * When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
113
+ * style.
114
+ *
115
+ * {
116
+ * list: {
117
+ * properties: {
118
+ * styles: {
119
+ * useAttribute: true
120
+ * },
121
+ *
122
+ * // ...
123
+ * }
124
+ * },
125
+ *
126
+ * // ...
127
+ * }
128
+ *
129
+ * **Note**: Due to limitations of HTML, the "Decimal with leading zero" style is impossible to set using the `type` attribute.
130
+ *
131
+ * **Note**: This configuration works only with {@link module:list/documentlistproperties~DocumentListProperties document list properties}.
132
+ *
133
+ * @default false
134
+ * @member {Boolean} module:list/listproperties~ListPropertiesStyleConfig#useAttribute
135
+ */