@ckeditor/ckeditor5-list 41.4.2 → 42.0.0-alpha.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 +6 -0
- package/dist/index.js +1059 -820
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/legacytodolist/legacytodolistediting.js +1 -1
- package/src/todolist/todolistediting.js +1 -1
package/dist/index.js
CHANGED
|
@@ -5,33 +5,82 @@
|
|
|
5
5
|
import { Command, Plugin, icons } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
6
|
import { Delete } from '@ckeditor/ckeditor5-typing/dist/index.js';
|
|
7
7
|
import { Enter } from '@ckeditor/ckeditor5-enter/dist/index.js';
|
|
8
|
-
import {
|
|
8
|
+
import { toArray, first, uid, CKEditorError, FocusTracker, KeystrokeHandler, global, getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection, createElement, logWarning } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
|
9
9
|
import { UpcastWriter, DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckeditor/ckeditor5-engine/dist/index.js';
|
|
10
10
|
import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
|
|
11
|
-
import { ButtonView, MenuBarMenuListItemButtonView, View, addKeyboardHandlingForGrid, CollapsibleView, LabeledFieldView, createLabeledInputNumber, SwitchButtonView,
|
|
11
|
+
import { ButtonView, MenuBarMenuListItemButtonView, View, ViewCollection, FocusCycler, addKeyboardHandlingForGrid, CollapsibleView, LabeledFieldView, createLabeledInputNumber, SwitchButtonView, createDropdown, SplitButtonView, focusChildOnDropdownOpen, MenuBarMenuView } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Document list blocks iterator.
|
|
15
|
+
*/ class ListWalker {
|
|
16
|
+
/**
|
|
17
|
+
* The start list item block element.
|
|
18
|
+
*/ _startElement;
|
|
19
|
+
/**
|
|
20
|
+
* The reference indent. Initialized by the indent of the start block.
|
|
21
|
+
*/ _referenceIndent;
|
|
22
|
+
/**
|
|
23
|
+
* The iterating direction.
|
|
24
|
+
*/ _isForward;
|
|
25
|
+
/**
|
|
26
|
+
* Whether start block should be included in the result (if it's matching other criteria).
|
|
27
|
+
*/ _includeSelf;
|
|
28
|
+
/**
|
|
29
|
+
* Additional attributes that must be the same for each block.
|
|
30
|
+
*/ _sameAttributes;
|
|
31
|
+
/**
|
|
32
|
+
* Whether blocks with the same indent level as the start block should be included in the result.
|
|
33
|
+
*/ _sameIndent;
|
|
34
|
+
/**
|
|
35
|
+
* Whether blocks with a lower indent level than the start block should be included in the result.
|
|
36
|
+
*/ _lowerIndent;
|
|
37
|
+
/**
|
|
38
|
+
* Whether blocks with a higher indent level than the start block should be included in the result.
|
|
39
|
+
*/ _higherIndent;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a document list iterator.
|
|
42
|
+
*
|
|
43
|
+
* @param startElement The start list item block element.
|
|
44
|
+
* @param options.direction The iterating direction.
|
|
45
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
46
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
47
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
48
|
+
* in the result.
|
|
49
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
50
|
+
* in the result.
|
|
51
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
52
|
+
* in the result.
|
|
53
|
+
*/ constructor(startElement, options){
|
|
54
|
+
this._startElement = startElement;
|
|
55
|
+
this._referenceIndent = startElement.getAttribute('listIndent');
|
|
56
|
+
this._isForward = options.direction == 'forward';
|
|
57
|
+
this._includeSelf = !!options.includeSelf;
|
|
58
|
+
this._sameAttributes = toArray(options.sameAttributes || []);
|
|
59
|
+
this._sameIndent = !!options.sameIndent;
|
|
60
|
+
this._lowerIndent = !!options.lowerIndent;
|
|
61
|
+
this._higherIndent = !!options.higherIndent;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Performs only first step of iteration and returns the result.
|
|
65
|
+
*
|
|
66
|
+
* @param startElement The start list item block element.
|
|
67
|
+
* @param options.direction The iterating direction.
|
|
68
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
69
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
70
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
71
|
+
* in the result.
|
|
72
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
73
|
+
* in the result.
|
|
74
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
75
|
+
* in the result.
|
|
76
|
+
*/ static first(startElement, options) {
|
|
28
77
|
const walker = new this(startElement, options);
|
|
29
78
|
const iterator = walker[Symbol.iterator]();
|
|
30
79
|
return first(iterator);
|
|
31
80
|
}
|
|
32
81
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
82
|
+
* Iterable interface.
|
|
83
|
+
*/ *[Symbol.iterator]() {
|
|
35
84
|
const nestedItems = [];
|
|
36
85
|
for (const { node } of iterateSiblingListBlocks(this._getStartNode(), this._isForward ? 'forward' : 'backward')){
|
|
37
86
|
const indent = node.getAttribute('listIndent');
|
|
@@ -81,36 +130,13 @@ class ListWalker {
|
|
|
81
130
|
}
|
|
82
131
|
}
|
|
83
132
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
133
|
+
* Returns the model element to start iterating.
|
|
134
|
+
*/ _getStartNode() {
|
|
86
135
|
if (this._includeSelf) {
|
|
87
136
|
return this._startElement;
|
|
88
137
|
}
|
|
89
138
|
return this._isForward ? this._startElement.nextSibling : this._startElement.previousSibling;
|
|
90
139
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Creates a document list iterator.
|
|
93
|
-
*
|
|
94
|
-
* @param startElement The start list item block element.
|
|
95
|
-
* @param options.direction The iterating direction.
|
|
96
|
-
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
97
|
-
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
98
|
-
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
99
|
-
* in the result.
|
|
100
|
-
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
101
|
-
* in the result.
|
|
102
|
-
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
103
|
-
* in the result.
|
|
104
|
-
*/ constructor(startElement, options){
|
|
105
|
-
this._startElement = startElement;
|
|
106
|
-
this._referenceIndent = startElement.getAttribute('listIndent');
|
|
107
|
-
this._isForward = options.direction == 'forward';
|
|
108
|
-
this._includeSelf = !!options.includeSelf;
|
|
109
|
-
this._sameAttributes = toArray(options.sameAttributes || []);
|
|
110
|
-
this._sameIndent = !!options.sameIndent;
|
|
111
|
-
this._lowerIndent = !!options.lowerIndent;
|
|
112
|
-
this._higherIndent = !!options.higherIndent;
|
|
113
|
-
}
|
|
114
140
|
}
|
|
115
141
|
/**
|
|
116
142
|
* Iterates sibling list blocks starting from the given node.
|
|
@@ -153,17 +179,18 @@ class ListWalker {
|
|
|
153
179
|
*
|
|
154
180
|
* @internal
|
|
155
181
|
*/ class ListBlocksIterable {
|
|
182
|
+
_listHead;
|
|
156
183
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
*/ [Symbol.iterator]() {
|
|
161
|
-
return iterateSiblingListBlocks(this._listHead, 'forward');
|
|
184
|
+
* @param listHead The head element of a list.
|
|
185
|
+
*/ constructor(listHead){
|
|
186
|
+
this._listHead = listHead;
|
|
162
187
|
}
|
|
163
188
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
189
|
+
* List blocks iterator.
|
|
190
|
+
*
|
|
191
|
+
* Iterates over all blocks of a list.
|
|
192
|
+
*/ [Symbol.iterator]() {
|
|
193
|
+
return iterateSiblingListBlocks(this._listHead, 'forward');
|
|
167
194
|
}
|
|
168
195
|
}
|
|
169
196
|
|
|
@@ -173,10 +200,10 @@ class ListWalker {
|
|
|
173
200
|
* @internal
|
|
174
201
|
*/ class ListItemUid {
|
|
175
202
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
203
|
+
* Returns the next ID.
|
|
204
|
+
*
|
|
205
|
+
* @internal
|
|
206
|
+
*/ /* istanbul ignore next: static function definition -- @preserve */ static next() {
|
|
180
207
|
return uid();
|
|
181
208
|
}
|
|
182
209
|
}
|
|
@@ -615,18 +642,33 @@ class ListWalker {
|
|
|
615
642
|
return [];
|
|
616
643
|
}
|
|
617
644
|
|
|
618
|
-
|
|
645
|
+
/**
|
|
646
|
+
* The document list indent command. It is used by the {@link module:list/list~List list feature}.
|
|
647
|
+
*/ class ListIndentCommand extends Command {
|
|
648
|
+
/**
|
|
649
|
+
* Determines by how much the command will change the list item's indent attribute.
|
|
650
|
+
*/ _direction;
|
|
651
|
+
/**
|
|
652
|
+
* Creates an instance of the command.
|
|
653
|
+
*
|
|
654
|
+
* @param editor The editor instance.
|
|
655
|
+
* @param indentDirection The direction of indent. If it is equal to `backward`, the command
|
|
656
|
+
* will outdent a list item.
|
|
657
|
+
*/ constructor(editor, indentDirection){
|
|
658
|
+
super(editor);
|
|
659
|
+
this._direction = indentDirection;
|
|
660
|
+
}
|
|
619
661
|
/**
|
|
620
|
-
|
|
621
|
-
|
|
662
|
+
* @inheritDoc
|
|
663
|
+
*/ refresh() {
|
|
622
664
|
this.isEnabled = this._checkEnabled();
|
|
623
665
|
}
|
|
624
666
|
/**
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
667
|
+
* Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
|
|
668
|
+
*
|
|
669
|
+
* @fires execute
|
|
670
|
+
* @fires afterExecute
|
|
671
|
+
*/ execute() {
|
|
630
672
|
const model = this.editor.model;
|
|
631
673
|
const blocks = getSelectedListBlocks(model.document.selection);
|
|
632
674
|
model.change((writer)=>{
|
|
@@ -667,17 +709,17 @@ class ListIndentCommand extends Command {
|
|
|
667
709
|
});
|
|
668
710
|
}
|
|
669
711
|
/**
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
712
|
+
* Fires the `afterExecute` event.
|
|
713
|
+
*
|
|
714
|
+
* @param changedBlocks The changed list elements.
|
|
715
|
+
*/ _fireAfterExecute(changedBlocks) {
|
|
674
716
|
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
675
717
|
}
|
|
676
718
|
/**
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
719
|
+
* Checks whether the command can be enabled in the current context.
|
|
720
|
+
*
|
|
721
|
+
* @returns Whether the command should be enabled.
|
|
722
|
+
*/ _checkEnabled() {
|
|
681
723
|
// Check whether any of position's ancestor is a list item.
|
|
682
724
|
let blocks = getSelectedListBlocks(this.editor.model.document.selection);
|
|
683
725
|
let firstBlock = blocks[0];
|
|
@@ -707,16 +749,6 @@ class ListIndentCommand extends Command {
|
|
|
707
749
|
}
|
|
708
750
|
return false;
|
|
709
751
|
}
|
|
710
|
-
/**
|
|
711
|
-
* Creates an instance of the command.
|
|
712
|
-
*
|
|
713
|
-
* @param editor The editor instance.
|
|
714
|
-
* @param indentDirection The direction of indent. If it is equal to `backward`, the command
|
|
715
|
-
* will outdent a list item.
|
|
716
|
-
*/ constructor(editor, indentDirection){
|
|
717
|
-
super(editor);
|
|
718
|
-
this._direction = indentDirection;
|
|
719
|
-
}
|
|
720
752
|
}
|
|
721
753
|
/**
|
|
722
754
|
* Returns an array of selected blocks truncated to the first non list block element.
|
|
@@ -729,24 +761,49 @@ class ListIndentCommand extends Command {
|
|
|
729
761
|
return blocks;
|
|
730
762
|
}
|
|
731
763
|
|
|
732
|
-
|
|
764
|
+
/**
|
|
765
|
+
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
766
|
+
*/ class ListCommand extends Command {
|
|
767
|
+
/**
|
|
768
|
+
* The type of the list created by the command.
|
|
769
|
+
*/ type;
|
|
770
|
+
/**
|
|
771
|
+
* List Walker options that change the range of the list items to be changed when the selection is collapsed within a list item.
|
|
772
|
+
*
|
|
773
|
+
* In a multi-level list, when the selection is collapsed within a list item, instead of changing only the list items of the same list
|
|
774
|
+
* type and current indent level, the entire list structure is changed (all list items at all indent levels of any list type).
|
|
775
|
+
*/ _listWalkerOptions;
|
|
776
|
+
/**
|
|
777
|
+
* Creates an instance of the command.
|
|
778
|
+
*
|
|
779
|
+
* @param editor The editor instance.
|
|
780
|
+
* @param type List type that will be handled by this command.
|
|
781
|
+
*/ constructor(editor, type, options = {}){
|
|
782
|
+
super(editor);
|
|
783
|
+
this.type = type;
|
|
784
|
+
this._listWalkerOptions = options.multiLevel ? {
|
|
785
|
+
higherIndent: true,
|
|
786
|
+
lowerIndent: true,
|
|
787
|
+
sameAttributes: []
|
|
788
|
+
} : undefined;
|
|
789
|
+
}
|
|
733
790
|
/**
|
|
734
|
-
|
|
735
|
-
|
|
791
|
+
* @inheritDoc
|
|
792
|
+
*/ refresh() {
|
|
736
793
|
this.value = this._getValue();
|
|
737
794
|
this.isEnabled = this._checkEnabled();
|
|
738
795
|
}
|
|
739
796
|
/**
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
797
|
+
* Executes the list command.
|
|
798
|
+
*
|
|
799
|
+
* @fires execute
|
|
800
|
+
* @fires afterExecute
|
|
801
|
+
* @param options Command options.
|
|
802
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
803
|
+
* selected items and potentially the neighbor elements to the proper list items. If set to `false` it will convert selected elements
|
|
804
|
+
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
805
|
+
* @param options.additionalAttributes Additional attributes that are set for list items when the command is executed.
|
|
806
|
+
*/ execute(options = {}) {
|
|
750
807
|
const model = this.editor.model;
|
|
751
808
|
const document = model.document;
|
|
752
809
|
const selectedBlockObject = getSelectedBlockObject(model);
|
|
@@ -813,17 +870,17 @@ class ListCommand extends Command {
|
|
|
813
870
|
});
|
|
814
871
|
}
|
|
815
872
|
/**
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
873
|
+
* Fires the `afterExecute` event.
|
|
874
|
+
*
|
|
875
|
+
* @param changedBlocks The changed list elements.
|
|
876
|
+
*/ _fireAfterExecute(changedBlocks) {
|
|
820
877
|
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
821
878
|
}
|
|
822
879
|
/**
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
880
|
+
* Checks the command's {@link #value}.
|
|
881
|
+
*
|
|
882
|
+
* @returns The current value.
|
|
883
|
+
*/ _getValue() {
|
|
827
884
|
const selection = this.editor.model.document.selection;
|
|
828
885
|
const blocks = Array.from(selection.getSelectedBlocks());
|
|
829
886
|
if (!blocks.length) {
|
|
@@ -837,10 +894,10 @@ class ListCommand extends Command {
|
|
|
837
894
|
return true;
|
|
838
895
|
}
|
|
839
896
|
/**
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
897
|
+
* Checks whether the command can be enabled in the current context.
|
|
898
|
+
*
|
|
899
|
+
* @returns Whether the command should be enabled.
|
|
900
|
+
*/ _checkEnabled() {
|
|
844
901
|
const model = this.editor.model;
|
|
845
902
|
const schema = model.schema;
|
|
846
903
|
const selection = model.document.selection;
|
|
@@ -859,38 +916,38 @@ class ListCommand extends Command {
|
|
|
859
916
|
}
|
|
860
917
|
return false;
|
|
861
918
|
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* The document list merge command. It is used by the {@link module:list/list~List list feature}.
|
|
923
|
+
*/ class ListMergeCommand extends Command {
|
|
924
|
+
/**
|
|
925
|
+
* Whether list item should be merged before or after the selected block.
|
|
926
|
+
*/ _direction;
|
|
862
927
|
/**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
928
|
+
* Creates an instance of the command.
|
|
929
|
+
*
|
|
930
|
+
* @param editor The editor instance.
|
|
931
|
+
* @param direction Whether list item should be merged before or after the selected block.
|
|
932
|
+
*/ constructor(editor, direction){
|
|
868
933
|
super(editor);
|
|
869
|
-
this.
|
|
870
|
-
this._listWalkerOptions = options.multiLevel ? {
|
|
871
|
-
higherIndent: true,
|
|
872
|
-
lowerIndent: true,
|
|
873
|
-
sameAttributes: []
|
|
874
|
-
} : undefined;
|
|
934
|
+
this._direction = direction;
|
|
875
935
|
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
class ListMergeCommand extends Command {
|
|
879
936
|
/**
|
|
880
|
-
|
|
881
|
-
|
|
937
|
+
* @inheritDoc
|
|
938
|
+
*/ refresh() {
|
|
882
939
|
this.isEnabled = this._checkEnabled();
|
|
883
940
|
}
|
|
884
941
|
/**
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
942
|
+
* Merges list blocks together (depending on the {@link #constructor}'s `direction` parameter).
|
|
943
|
+
*
|
|
944
|
+
* @fires execute
|
|
945
|
+
* @fires afterExecute
|
|
946
|
+
* @param options Command options.
|
|
947
|
+
* @param options.shouldMergeOnBlocksContentLevel When set `true`, merging will be performed together
|
|
948
|
+
* with {@link module:engine/model/model~Model#deleteContent} to get rid of the inline content in the selection or take advantage
|
|
949
|
+
* of the heuristics in `deleteContent()` that helps convert lists into paragraphs in certain cases.
|
|
950
|
+
*/ execute({ shouldMergeOnBlocksContentLevel = false } = {}) {
|
|
894
951
|
const model = this.editor.model;
|
|
895
952
|
const selection = model.document.selection;
|
|
896
953
|
const changedBlocks = [];
|
|
@@ -935,17 +992,17 @@ class ListMergeCommand extends Command {
|
|
|
935
992
|
});
|
|
936
993
|
}
|
|
937
994
|
/**
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
995
|
+
* Fires the `afterExecute` event.
|
|
996
|
+
*
|
|
997
|
+
* @param changedBlocks The changed list elements.
|
|
998
|
+
*/ _fireAfterExecute(changedBlocks) {
|
|
942
999
|
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
943
1000
|
}
|
|
944
1001
|
/**
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1002
|
+
* Checks whether the command can be enabled in the current context.
|
|
1003
|
+
*
|
|
1004
|
+
* @returns Whether the command should be enabled.
|
|
1005
|
+
*/ _checkEnabled() {
|
|
949
1006
|
const model = this.editor.model;
|
|
950
1007
|
const selection = model.document.selection;
|
|
951
1008
|
const selectedBlockObject = getSelectedBlockObject(model);
|
|
@@ -979,13 +1036,13 @@ class ListMergeCommand extends Command {
|
|
|
979
1036
|
return true;
|
|
980
1037
|
}
|
|
981
1038
|
/**
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1039
|
+
* Returns the boundary elements the merge should be executed for. These are not necessarily selection's first
|
|
1040
|
+
* and last position parents but sometimes sibling or even further blocks depending on the context.
|
|
1041
|
+
*
|
|
1042
|
+
* @param selection The selection the merge is executed for.
|
|
1043
|
+
* @param shouldMergeOnBlocksContentLevel When `true`, merge is performed together with
|
|
1044
|
+
* {@link module:engine/model/model~Model#deleteContent} to remove the inline content within the selection.
|
|
1045
|
+
*/ _getMergeSubjectElements(selection, shouldMergeOnBlocksContentLevel) {
|
|
989
1046
|
const model = this.editor.model;
|
|
990
1047
|
const selectedBlockObject = getSelectedBlockObject(model);
|
|
991
1048
|
let firstElement, lastElement;
|
|
@@ -1024,29 +1081,36 @@ class ListMergeCommand extends Command {
|
|
|
1024
1081
|
lastElement: lastElement
|
|
1025
1082
|
};
|
|
1026
1083
|
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* The document list split command that splits the list item at the selection.
|
|
1088
|
+
*
|
|
1089
|
+
* It is used by the {@link module:list/list~List list feature}.
|
|
1090
|
+
*/ class ListSplitCommand extends Command {
|
|
1091
|
+
/**
|
|
1092
|
+
* Whether list item should be split before or after the selected block.
|
|
1093
|
+
*/ _direction;
|
|
1027
1094
|
/**
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1095
|
+
* Creates an instance of the command.
|
|
1096
|
+
*
|
|
1097
|
+
* @param editor The editor instance.
|
|
1098
|
+
* @param direction Whether list item should be split before or after the selected block.
|
|
1099
|
+
*/ constructor(editor, direction){
|
|
1033
1100
|
super(editor);
|
|
1034
1101
|
this._direction = direction;
|
|
1035
1102
|
}
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
class ListSplitCommand extends Command {
|
|
1039
1103
|
/**
|
|
1040
|
-
|
|
1041
|
-
|
|
1104
|
+
* @inheritDoc
|
|
1105
|
+
*/ refresh() {
|
|
1042
1106
|
this.isEnabled = this._checkEnabled();
|
|
1043
1107
|
}
|
|
1044
1108
|
/**
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1109
|
+
* Splits the list item at the selection.
|
|
1110
|
+
*
|
|
1111
|
+
* @fires execute
|
|
1112
|
+
* @fires afterExecute
|
|
1113
|
+
*/ execute() {
|
|
1050
1114
|
const editor = this.editor;
|
|
1051
1115
|
editor.model.change((writer)=>{
|
|
1052
1116
|
const changedBlocks = splitListItemBefore(this._getStartBlock(), writer);
|
|
@@ -1054,77 +1118,70 @@ class ListSplitCommand extends Command {
|
|
|
1054
1118
|
});
|
|
1055
1119
|
}
|
|
1056
1120
|
/**
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1121
|
+
* Fires the `afterExecute` event.
|
|
1122
|
+
*
|
|
1123
|
+
* @param changedBlocks The changed list elements.
|
|
1124
|
+
*/ _fireAfterExecute(changedBlocks) {
|
|
1061
1125
|
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
1062
1126
|
}
|
|
1063
1127
|
/**
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1128
|
+
* Checks whether the command can be enabled in the current context.
|
|
1129
|
+
*
|
|
1130
|
+
* @returns Whether the command should be enabled.
|
|
1131
|
+
*/ _checkEnabled() {
|
|
1068
1132
|
const selection = this.editor.model.document.selection;
|
|
1069
1133
|
const block = this._getStartBlock();
|
|
1070
1134
|
return selection.isCollapsed && isListItemBlock(block) && !isFirstBlockOfListItem(block);
|
|
1071
1135
|
}
|
|
1072
1136
|
/**
|
|
1073
|
-
|
|
1074
|
-
|
|
1137
|
+
* Returns the model element that is the main focus of the command (according to the current selection and command direction).
|
|
1138
|
+
*/ _getStartBlock() {
|
|
1075
1139
|
const doc = this.editor.model.document;
|
|
1076
1140
|
const positionParent = doc.selection.getFirstPosition().parent;
|
|
1077
1141
|
return this._direction == 'before' ? positionParent : positionParent.nextSibling;
|
|
1078
1142
|
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Creates an instance of the command.
|
|
1081
|
-
*
|
|
1082
|
-
* @param editor The editor instance.
|
|
1083
|
-
* @param direction Whether list item should be split before or after the selected block.
|
|
1084
|
-
*/ constructor(editor, direction){
|
|
1085
|
-
super(editor);
|
|
1086
|
-
this._direction = direction;
|
|
1087
|
-
}
|
|
1088
1143
|
}
|
|
1089
1144
|
|
|
1090
|
-
|
|
1145
|
+
/**
|
|
1146
|
+
* A set of helpers related to document lists.
|
|
1147
|
+
*/ class ListUtils extends Plugin {
|
|
1091
1148
|
/**
|
|
1092
|
-
|
|
1093
|
-
|
|
1149
|
+
* @inheritDoc
|
|
1150
|
+
*/ static get pluginName() {
|
|
1094
1151
|
return 'ListUtils';
|
|
1095
1152
|
}
|
|
1096
1153
|
/**
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1154
|
+
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
1155
|
+
*
|
|
1156
|
+
* @param blocks The list of selected blocks.
|
|
1157
|
+
*/ expandListBlocksToCompleteList(blocks) {
|
|
1101
1158
|
return expandListBlocksToCompleteList(blocks);
|
|
1102
1159
|
}
|
|
1103
1160
|
/**
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1161
|
+
* Check if the given block is the first in the list item.
|
|
1162
|
+
*
|
|
1163
|
+
* @param listBlock The list block element.
|
|
1164
|
+
*/ isFirstBlockOfListItem(listBlock) {
|
|
1108
1165
|
return isFirstBlockOfListItem(listBlock);
|
|
1109
1166
|
}
|
|
1110
1167
|
/**
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1168
|
+
* Returns true if the given model node is a list item block.
|
|
1169
|
+
*
|
|
1170
|
+
* @param node A model node.
|
|
1171
|
+
*/ isListItemBlock(node) {
|
|
1115
1172
|
return isListItemBlock(node);
|
|
1116
1173
|
}
|
|
1117
1174
|
/**
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1175
|
+
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
1176
|
+
*
|
|
1177
|
+
* @param blocks The list of selected blocks.
|
|
1178
|
+
* @param options.withNested Whether should include nested list items.
|
|
1179
|
+
*/ expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
1123
1180
|
return expandListBlocksToCompleteItems(blocks, options);
|
|
1124
1181
|
}
|
|
1125
1182
|
/**
|
|
1126
|
-
|
|
1127
|
-
|
|
1183
|
+
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
1184
|
+
*/ isNumberedListType(listType) {
|
|
1128
1185
|
return isNumberedListType(listType);
|
|
1129
1186
|
}
|
|
1130
1187
|
}
|
|
@@ -1133,6 +1190,8 @@ class ListUtils extends Plugin {
|
|
|
1133
1190
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
1134
1191
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
1135
1192
|
*/ /**
|
|
1193
|
+
* @module list/list/utils/view
|
|
1194
|
+
*/ /**
|
|
1136
1195
|
* Checks if view element is a list type (ul or ol).
|
|
1137
1196
|
*
|
|
1138
1197
|
* @internal
|
|
@@ -1860,15 +1919,20 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
1860
1919
|
'listIndent',
|
|
1861
1920
|
'listItemId'
|
|
1862
1921
|
];
|
|
1863
|
-
|
|
1922
|
+
/**
|
|
1923
|
+
* The editing part of the document-list feature. It handles creating, editing and removing lists and list items.
|
|
1924
|
+
*/ class ListEditing extends Plugin {
|
|
1925
|
+
/**
|
|
1926
|
+
* The list of registered downcast strategies.
|
|
1927
|
+
*/ _downcastStrategies = [];
|
|
1864
1928
|
/**
|
|
1865
|
-
|
|
1866
|
-
|
|
1929
|
+
* @inheritDoc
|
|
1930
|
+
*/ static get pluginName() {
|
|
1867
1931
|
return 'ListEditing';
|
|
1868
1932
|
}
|
|
1869
1933
|
/**
|
|
1870
|
-
|
|
1871
|
-
|
|
1934
|
+
* @inheritDoc
|
|
1935
|
+
*/ static get requires() {
|
|
1872
1936
|
return [
|
|
1873
1937
|
Enter,
|
|
1874
1938
|
Delete,
|
|
@@ -1877,18 +1941,24 @@ class ListEditing extends Plugin {
|
|
|
1877
1941
|
];
|
|
1878
1942
|
}
|
|
1879
1943
|
/**
|
|
1880
|
-
|
|
1881
|
-
|
|
1944
|
+
* @inheritDoc
|
|
1945
|
+
*/ constructor(editor){
|
|
1946
|
+
super(editor);
|
|
1947
|
+
editor.config.define('list.multiBlock', true);
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* @inheritDoc
|
|
1951
|
+
*/ init() {
|
|
1882
1952
|
const editor = this.editor;
|
|
1883
1953
|
const model = editor.model;
|
|
1884
1954
|
const multiBlock = editor.config.get('list.multiBlock');
|
|
1885
1955
|
if (editor.plugins.has('LegacyListEditing')) {
|
|
1886
1956
|
/**
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1957
|
+
* The `List` feature can not be loaded together with the `LegacyList` plugin.
|
|
1958
|
+
*
|
|
1959
|
+
* @error list-feature-conflict
|
|
1960
|
+
* @param conflictPlugin Name of the plugin.
|
|
1961
|
+
*/ throw new CKEditorError('list-feature-conflict', this, {
|
|
1892
1962
|
conflictPlugin: 'LegacyListEditing'
|
|
1893
1963
|
});
|
|
1894
1964
|
}
|
|
@@ -1940,8 +2010,8 @@ class ListEditing extends Plugin {
|
|
|
1940
2010
|
this._setupAccessibilityIntegration();
|
|
1941
2011
|
}
|
|
1942
2012
|
/**
|
|
1943
|
-
|
|
1944
|
-
|
|
2013
|
+
* @inheritDoc
|
|
2014
|
+
*/ afterInit() {
|
|
1945
2015
|
const editor = this.editor;
|
|
1946
2016
|
const commands = editor.commands;
|
|
1947
2017
|
const indent = commands.get('indent');
|
|
@@ -1965,27 +2035,27 @@ class ListEditing extends Plugin {
|
|
|
1965
2035
|
this._setupConversion();
|
|
1966
2036
|
}
|
|
1967
2037
|
/**
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
2038
|
+
* Registers a downcast strategy.
|
|
2039
|
+
*
|
|
2040
|
+
* **Note**: Strategies must be registered in the `Plugin#init()` phase so that it can be applied
|
|
2041
|
+
* in the `ListEditing#afterInit()`.
|
|
2042
|
+
*
|
|
2043
|
+
* @param strategy The downcast strategy to register.
|
|
2044
|
+
*/ registerDowncastStrategy(strategy) {
|
|
1975
2045
|
this._downcastStrategies.push(strategy);
|
|
1976
2046
|
}
|
|
1977
2047
|
/**
|
|
1978
|
-
|
|
1979
|
-
|
|
2048
|
+
* Returns list of model attribute names that should affect downcast conversion.
|
|
2049
|
+
*/ getListAttributeNames() {
|
|
1980
2050
|
return [
|
|
1981
2051
|
...LIST_BASE_ATTRIBUTES,
|
|
1982
2052
|
...this._downcastStrategies.map((strategy)=>strategy.attributeName)
|
|
1983
2053
|
];
|
|
1984
2054
|
}
|
|
1985
2055
|
/**
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2056
|
+
* Attaches the listener to the {@link module:engine/view/document~Document#event:delete} event and handles backspace/delete
|
|
2057
|
+
* keys in and around document lists.
|
|
2058
|
+
*/ _setupDeleteIntegration() {
|
|
1989
2059
|
const editor = this.editor;
|
|
1990
2060
|
const mergeBackwardCommand = editor.commands.get('mergeListItemBackward');
|
|
1991
2061
|
const mergeForwardCommand = editor.commands.get('mergeListItemForward');
|
|
@@ -2045,9 +2115,9 @@ class ListEditing extends Plugin {
|
|
|
2045
2115
|
});
|
|
2046
2116
|
}
|
|
2047
2117
|
/**
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2118
|
+
* Attaches a listener to the {@link module:engine/view/document~Document#event:enter} event and handles enter key press
|
|
2119
|
+
* in document lists.
|
|
2120
|
+
*/ _setupEnterIntegration() {
|
|
2051
2121
|
const editor = this.editor;
|
|
2052
2122
|
const model = editor.model;
|
|
2053
2123
|
const commands = editor.commands;
|
|
@@ -2103,9 +2173,9 @@ class ListEditing extends Plugin {
|
|
|
2103
2173
|
});
|
|
2104
2174
|
}
|
|
2105
2175
|
/**
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2176
|
+
* Attaches a listener to the {@link module:engine/view/document~Document#event:tab} event and handles tab key and tab+shift keys
|
|
2177
|
+
* presses in document lists.
|
|
2178
|
+
*/ _setupTabIntegration() {
|
|
2109
2179
|
const editor = this.editor;
|
|
2110
2180
|
this.listenTo(editor.editing.view.document, 'tab', (evt, data)=>{
|
|
2111
2181
|
const commandName = data.shiftKey ? 'outdentList' : 'indentList';
|
|
@@ -2121,8 +2191,8 @@ class ListEditing extends Plugin {
|
|
|
2121
2191
|
});
|
|
2122
2192
|
}
|
|
2123
2193
|
/**
|
|
2124
|
-
|
|
2125
|
-
|
|
2194
|
+
* Registers the conversion helpers for the document-list feature.
|
|
2195
|
+
*/ _setupConversion() {
|
|
2126
2196
|
const editor = this.editor;
|
|
2127
2197
|
const model = editor.model;
|
|
2128
2198
|
const attributeNames = this.getListAttributeNames();
|
|
@@ -2210,8 +2280,8 @@ class ListEditing extends Plugin {
|
|
|
2210
2280
|
});
|
|
2211
2281
|
}
|
|
2212
2282
|
/**
|
|
2213
|
-
|
|
2214
|
-
|
|
2283
|
+
* Registers model post-fixers.
|
|
2284
|
+
*/ _setupModelPostFixing() {
|
|
2215
2285
|
const model = this.editor.model;
|
|
2216
2286
|
const attributeNames = this.getListAttributeNames();
|
|
2217
2287
|
// Register list fixing.
|
|
@@ -2232,9 +2302,9 @@ class ListEditing extends Plugin {
|
|
|
2232
2302
|
});
|
|
2233
2303
|
}
|
|
2234
2304
|
/**
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2305
|
+
* Integrates the feature with the clipboard via {@link module:engine/model/model~Model#insertContent} and
|
|
2306
|
+
* {@link module:engine/model/model~Model#getSelectedContent}.
|
|
2307
|
+
*/ _setupClipboardIntegration() {
|
|
2238
2308
|
const model = this.editor.model;
|
|
2239
2309
|
const clipboardPipeline = this.editor.plugins.get('ClipboardPipeline');
|
|
2240
2310
|
this.listenTo(model, 'insertContent', createModelIndentPasteFixer(model), {
|
|
@@ -2291,8 +2361,8 @@ class ListEditing extends Plugin {
|
|
|
2291
2361
|
});
|
|
2292
2362
|
}
|
|
2293
2363
|
/**
|
|
2294
|
-
|
|
2295
|
-
|
|
2364
|
+
* Informs editor accessibility features about keystrokes brought by the plugin.
|
|
2365
|
+
*/ _setupAccessibilityIntegration() {
|
|
2296
2366
|
const editor = this.editor;
|
|
2297
2367
|
const t = editor.t;
|
|
2298
2368
|
editor.accessibility.addKeystrokeInfoGroup({
|
|
@@ -2310,15 +2380,6 @@ class ListEditing extends Plugin {
|
|
|
2310
2380
|
]
|
|
2311
2381
|
});
|
|
2312
2382
|
}
|
|
2313
|
-
/**
|
|
2314
|
-
* @inheritDoc
|
|
2315
|
-
*/ constructor(editor){
|
|
2316
|
-
super(editor);
|
|
2317
|
-
/**
|
|
2318
|
-
* The list of registered downcast strategies.
|
|
2319
|
-
*/ this._downcastStrategies = [];
|
|
2320
|
-
editor.config.define('list.multiBlock', true);
|
|
2321
|
-
}
|
|
2322
2383
|
}
|
|
2323
2384
|
/**
|
|
2324
2385
|
* Post-fixer that reacts to changes on document and fixes incorrect model states (invalid `listItemId` and `listIndent` values).
|
|
@@ -2462,11 +2523,11 @@ class ListEditing extends Plugin {
|
|
|
2462
2523
|
const isListItem = isListItemBlock(item);
|
|
2463
2524
|
if (refItem.is('element', 'listItem') && item.is('element', 'paragraph')) {
|
|
2464
2525
|
/**
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2526
|
+
* When paragraphs or a plain text list is pasted into a simple list, convert
|
|
2527
|
+
* the `<paragraphs>' to `<listItem>' to avoid breaking the target list.
|
|
2528
|
+
*
|
|
2529
|
+
* See https://github.com/ckeditor/ckeditor5/issues/13826.
|
|
2530
|
+
*/ writer.rename(item, 'listItem');
|
|
2470
2531
|
}
|
|
2471
2532
|
writer.setAttributes({
|
|
2472
2533
|
listIndent: (isListItem ? item.getAttribute('listIndent') : 0) + indentDiff,
|
|
@@ -2542,15 +2603,18 @@ class ListEditing extends Plugin {
|
|
|
2542
2603
|
return view;
|
|
2543
2604
|
}
|
|
2544
2605
|
|
|
2545
|
-
|
|
2606
|
+
/**
|
|
2607
|
+
* The list UI feature. It introduces the `'numberedList'` and `'bulletedList'` buttons that
|
|
2608
|
+
* allow to convert paragraphs to and from list items and indent or outdent them.
|
|
2609
|
+
*/ class ListUI extends Plugin {
|
|
2546
2610
|
/**
|
|
2547
|
-
|
|
2548
|
-
|
|
2611
|
+
* @inheritDoc
|
|
2612
|
+
*/ static get pluginName() {
|
|
2549
2613
|
return 'ListUI';
|
|
2550
2614
|
}
|
|
2551
2615
|
/**
|
|
2552
|
-
|
|
2553
|
-
|
|
2616
|
+
* @inheritDoc
|
|
2617
|
+
*/ init() {
|
|
2554
2618
|
const t = this.editor.t;
|
|
2555
2619
|
// Create button numberedList.
|
|
2556
2620
|
if (!this.editor.ui.componentFactory.has('numberedList')) {
|
|
@@ -2563,36 +2627,45 @@ class ListUI extends Plugin {
|
|
|
2563
2627
|
}
|
|
2564
2628
|
}
|
|
2565
2629
|
|
|
2566
|
-
|
|
2630
|
+
/**
|
|
2631
|
+
* The list feature.
|
|
2632
|
+
*
|
|
2633
|
+
* This is a "glue" plugin that loads the {@link module:list/list/listediting~ListEditing list
|
|
2634
|
+
* editing feature} and {@link module:list/list/listui~ListUI list UI feature}.
|
|
2635
|
+
*/ class List extends Plugin {
|
|
2567
2636
|
/**
|
|
2568
|
-
|
|
2569
|
-
|
|
2637
|
+
* @inheritDoc
|
|
2638
|
+
*/ static get requires() {
|
|
2570
2639
|
return [
|
|
2571
2640
|
ListEditing,
|
|
2572
2641
|
ListUI
|
|
2573
2642
|
];
|
|
2574
2643
|
}
|
|
2575
2644
|
/**
|
|
2576
|
-
|
|
2577
|
-
|
|
2645
|
+
* @inheritDoc
|
|
2646
|
+
*/ static get pluginName() {
|
|
2578
2647
|
return 'List';
|
|
2579
2648
|
}
|
|
2580
2649
|
}
|
|
2581
2650
|
|
|
2582
|
-
|
|
2651
|
+
/**
|
|
2652
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
2653
|
+
* letting the user to choose the starting point of an ordered list.
|
|
2654
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
2655
|
+
*/ class ListStartCommand extends Command {
|
|
2583
2656
|
/**
|
|
2584
|
-
|
|
2585
|
-
|
|
2657
|
+
* @inheritDoc
|
|
2658
|
+
*/ refresh() {
|
|
2586
2659
|
const value = this._getValue();
|
|
2587
2660
|
this.value = value;
|
|
2588
2661
|
this.isEnabled = value != null;
|
|
2589
2662
|
}
|
|
2590
2663
|
/**
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2664
|
+
* Executes the command.
|
|
2665
|
+
*
|
|
2666
|
+
* @fires execute
|
|
2667
|
+
* @param options.startIndex The list start index.
|
|
2668
|
+
*/ execute({ startIndex = 1 } = {}) {
|
|
2596
2669
|
const model = this.editor.model;
|
|
2597
2670
|
const document = model.document;
|
|
2598
2671
|
let blocks = Array.from(document.selection.getSelectedBlocks()).filter((block)=>isListItemBlock(block) && isNumberedListType(block.getAttribute('listType')));
|
|
@@ -2604,10 +2677,10 @@ class ListStartCommand extends Command {
|
|
|
2604
2677
|
});
|
|
2605
2678
|
}
|
|
2606
2679
|
/**
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2680
|
+
* Checks the command's {@link #value}.
|
|
2681
|
+
*
|
|
2682
|
+
* @returns The current value.
|
|
2683
|
+
*/ _getValue() {
|
|
2611
2684
|
const model = this.editor.model;
|
|
2612
2685
|
const document = model.document;
|
|
2613
2686
|
const block = first(document.selection.getSelectedBlocks());
|
|
@@ -2711,20 +2784,42 @@ for (const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES){
|
|
|
2711
2784
|
return LIST_STYLE_TO_TYPE_ATTRIBUTE[value] || null;
|
|
2712
2785
|
}
|
|
2713
2786
|
|
|
2714
|
-
|
|
2787
|
+
/**
|
|
2788
|
+
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
2789
|
+
* letting the user choose styles for the list item markers.
|
|
2790
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
2791
|
+
*/ class ListStyleCommand extends Command {
|
|
2792
|
+
/**
|
|
2793
|
+
* The default type of the list style.
|
|
2794
|
+
*/ defaultType;
|
|
2795
|
+
/**
|
|
2796
|
+
* The list of supported style types by this command.
|
|
2797
|
+
*/ _supportedTypes;
|
|
2798
|
+
/**
|
|
2799
|
+
* Creates an instance of the command.
|
|
2800
|
+
*
|
|
2801
|
+
* @param editor The editor instance.
|
|
2802
|
+
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
2803
|
+
* the command execution.
|
|
2804
|
+
* @param supportedTypes The list of supported style types by this command.
|
|
2805
|
+
*/ constructor(editor, defaultType, supportedTypes){
|
|
2806
|
+
super(editor);
|
|
2807
|
+
this.defaultType = defaultType;
|
|
2808
|
+
this._supportedTypes = supportedTypes;
|
|
2809
|
+
}
|
|
2715
2810
|
/**
|
|
2716
|
-
|
|
2717
|
-
|
|
2811
|
+
* @inheritDoc
|
|
2812
|
+
*/ refresh() {
|
|
2718
2813
|
this.value = this._getValue();
|
|
2719
2814
|
this.isEnabled = this._checkEnabled();
|
|
2720
2815
|
}
|
|
2721
2816
|
/**
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2817
|
+
* Executes the command.
|
|
2818
|
+
*
|
|
2819
|
+
* @fires execute
|
|
2820
|
+
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
2821
|
+
* style will be applied.
|
|
2822
|
+
*/ execute(options = {}) {
|
|
2728
2823
|
const model = this.editor.model;
|
|
2729
2824
|
const document = model.document;
|
|
2730
2825
|
model.change((writer)=>{
|
|
@@ -2740,18 +2835,18 @@ class ListStyleCommand extends Command {
|
|
|
2740
2835
|
});
|
|
2741
2836
|
}
|
|
2742
2837
|
/**
|
|
2743
|
-
|
|
2744
|
-
|
|
2838
|
+
* Checks if the given style type is supported by this plugin.
|
|
2839
|
+
*/ isStyleTypeSupported(value) {
|
|
2745
2840
|
if (!this._supportedTypes) {
|
|
2746
2841
|
return true;
|
|
2747
2842
|
}
|
|
2748
2843
|
return this._supportedTypes.includes(value);
|
|
2749
2844
|
}
|
|
2750
2845
|
/**
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2846
|
+
* Checks the command's {@link #value}.
|
|
2847
|
+
*
|
|
2848
|
+
* @returns The current value.
|
|
2849
|
+
*/ _getValue() {
|
|
2755
2850
|
const listItem = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
2756
2851
|
if (isListItemBlock(listItem)) {
|
|
2757
2852
|
return listItem.getAttribute('listStyle');
|
|
@@ -2759,20 +2854,20 @@ class ListStyleCommand extends Command {
|
|
|
2759
2854
|
return null;
|
|
2760
2855
|
}
|
|
2761
2856
|
/**
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2857
|
+
* Checks whether the command can be enabled in the current context.
|
|
2858
|
+
*
|
|
2859
|
+
* @returns Whether the command should be enabled.
|
|
2860
|
+
*/ _checkEnabled() {
|
|
2766
2861
|
const editor = this.editor;
|
|
2767
2862
|
const numberedList = editor.commands.get('numberedList');
|
|
2768
2863
|
const bulletedList = editor.commands.get('bulletedList');
|
|
2769
2864
|
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
2770
2865
|
}
|
|
2771
2866
|
/**
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2867
|
+
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
2868
|
+
*
|
|
2869
|
+
* @param options.type The type of the list style. If `null` is specified, the function does nothing.
|
|
2870
|
+
*/ _tryToConvertItemsToList(options) {
|
|
2776
2871
|
if (!options.type) {
|
|
2777
2872
|
return;
|
|
2778
2873
|
}
|
|
@@ -2787,34 +2882,26 @@ class ListStyleCommand extends Command {
|
|
|
2787
2882
|
editor.execute(commandName);
|
|
2788
2883
|
}
|
|
2789
2884
|
}
|
|
2790
|
-
/**
|
|
2791
|
-
* Creates an instance of the command.
|
|
2792
|
-
*
|
|
2793
|
-
* @param editor The editor instance.
|
|
2794
|
-
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
2795
|
-
* the command execution.
|
|
2796
|
-
* @param supportedTypes The list of supported style types by this command.
|
|
2797
|
-
*/ constructor(editor, defaultType, supportedTypes){
|
|
2798
|
-
super(editor);
|
|
2799
|
-
this.defaultType = defaultType;
|
|
2800
|
-
this._supportedTypes = supportedTypes;
|
|
2801
|
-
}
|
|
2802
2885
|
}
|
|
2803
2886
|
|
|
2804
|
-
|
|
2887
|
+
/**
|
|
2888
|
+
* The list reversed command. It changes the `listReversed` attribute of the selected list items,
|
|
2889
|
+
* letting the user to choose the order of an ordered list.
|
|
2890
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
2891
|
+
*/ class ListReversedCommand extends Command {
|
|
2805
2892
|
/**
|
|
2806
|
-
|
|
2807
|
-
|
|
2893
|
+
* @inheritDoc
|
|
2894
|
+
*/ refresh() {
|
|
2808
2895
|
const value = this._getValue();
|
|
2809
2896
|
this.value = value;
|
|
2810
2897
|
this.isEnabled = value != null;
|
|
2811
2898
|
}
|
|
2812
2899
|
/**
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2900
|
+
* Executes the command.
|
|
2901
|
+
*
|
|
2902
|
+
* @fires execute
|
|
2903
|
+
* @param options.reversed Whether the list should be reversed.
|
|
2904
|
+
*/ execute(options = {}) {
|
|
2818
2905
|
const model = this.editor.model;
|
|
2819
2906
|
const document = model.document;
|
|
2820
2907
|
let blocks = Array.from(document.selection.getSelectedBlocks()).filter((block)=>isListItemBlock(block) && block.getAttribute('listType') == 'numbered');
|
|
@@ -2826,8 +2913,8 @@ class ListReversedCommand extends Command {
|
|
|
2826
2913
|
});
|
|
2827
2914
|
}
|
|
2828
2915
|
/**
|
|
2829
|
-
|
|
2830
|
-
|
|
2916
|
+
* Checks the command's {@link #value}.
|
|
2917
|
+
*/ _getValue() {
|
|
2831
2918
|
const model = this.editor.model;
|
|
2832
2919
|
const document = model.document;
|
|
2833
2920
|
const block = first(document.selection.getSelectedBlocks());
|
|
@@ -2842,6 +2929,8 @@ class ListReversedCommand extends Command {
|
|
|
2842
2929
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
2843
2930
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
2844
2931
|
*/ /**
|
|
2932
|
+
* @module list/listproperties/converters
|
|
2933
|
+
*/ /**
|
|
2845
2934
|
* Returns a converter that consumes the `style`, `reversed`, and `start` attributes.
|
|
2846
2935
|
* In `style`, it searches for the `list-style-type` definition.
|
|
2847
2936
|
* If not found, the `"default"` value will be used.
|
|
@@ -2882,52 +2971,69 @@ class ListReversedCommand extends Command {
|
|
|
2882
2971
|
};
|
|
2883
2972
|
}
|
|
2884
2973
|
|
|
2885
|
-
|
|
2974
|
+
/**
|
|
2975
|
+
* A set of helpers related to document lists.
|
|
2976
|
+
*/ class ListPropertiesUtils extends Plugin {
|
|
2886
2977
|
/**
|
|
2887
|
-
|
|
2888
|
-
|
|
2978
|
+
* @inheritDoc
|
|
2979
|
+
*/ static get pluginName() {
|
|
2889
2980
|
return 'ListPropertiesUtils';
|
|
2890
2981
|
}
|
|
2891
2982
|
/**
|
|
2892
|
-
|
|
2893
|
-
|
|
2983
|
+
* Gets all the style types supported by given list type.
|
|
2984
|
+
*/ getAllSupportedStyleTypes() {
|
|
2894
2985
|
return getAllSupportedStyleTypes();
|
|
2895
2986
|
}
|
|
2896
2987
|
/**
|
|
2897
|
-
|
|
2898
|
-
|
|
2988
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
2989
|
+
*/ getListTypeFromListStyleType(listStyleType) {
|
|
2899
2990
|
return getListTypeFromListStyleType$1(listStyleType);
|
|
2900
2991
|
}
|
|
2901
2992
|
/**
|
|
2902
|
-
|
|
2903
|
-
|
|
2993
|
+
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
2994
|
+
*/ getListStyleTypeFromTypeAttribute(value) {
|
|
2904
2995
|
return getListStyleTypeFromTypeAttribute(value);
|
|
2905
2996
|
}
|
|
2906
2997
|
/**
|
|
2907
|
-
|
|
2908
|
-
|
|
2998
|
+
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
2999
|
+
*/ getTypeAttributeFromListStyleType(value) {
|
|
2909
3000
|
return getTypeAttributeFromListStyleType(value);
|
|
2910
3001
|
}
|
|
2911
3002
|
}
|
|
2912
3003
|
|
|
2913
3004
|
const DEFAULT_LIST_TYPE$1 = 'default';
|
|
2914
|
-
|
|
3005
|
+
/**
|
|
3006
|
+
* The document list properties engine feature.
|
|
3007
|
+
*
|
|
3008
|
+
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
3009
|
+
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
3010
|
+
*/ class ListPropertiesEditing extends Plugin {
|
|
2915
3011
|
/**
|
|
2916
|
-
|
|
2917
|
-
|
|
3012
|
+
* @inheritDoc
|
|
3013
|
+
*/ static get requires() {
|
|
2918
3014
|
return [
|
|
2919
3015
|
ListEditing,
|
|
2920
3016
|
ListPropertiesUtils
|
|
2921
3017
|
];
|
|
2922
3018
|
}
|
|
2923
3019
|
/**
|
|
2924
|
-
|
|
2925
|
-
|
|
3020
|
+
* @inheritDoc
|
|
3021
|
+
*/ static get pluginName() {
|
|
2926
3022
|
return 'ListPropertiesEditing';
|
|
2927
3023
|
}
|
|
2928
3024
|
/**
|
|
2929
|
-
|
|
2930
|
-
|
|
3025
|
+
* @inheritDoc
|
|
3026
|
+
*/ constructor(editor){
|
|
3027
|
+
super(editor);
|
|
3028
|
+
editor.config.define('list.properties', {
|
|
3029
|
+
styles: true,
|
|
3030
|
+
startIndex: false,
|
|
3031
|
+
reversed: false
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* @inheritDoc
|
|
3036
|
+
*/ init() {
|
|
2931
3037
|
const editor = this.editor;
|
|
2932
3038
|
const model = editor.model;
|
|
2933
3039
|
const listEditing = editor.plugins.get(ListEditing);
|
|
@@ -3022,16 +3128,6 @@ class ListPropertiesEditing extends Plugin {
|
|
|
3022
3128
|
}
|
|
3023
3129
|
});
|
|
3024
3130
|
}
|
|
3025
|
-
/**
|
|
3026
|
-
* @inheritDoc
|
|
3027
|
-
*/ constructor(editor){
|
|
3028
|
-
super(editor);
|
|
3029
|
-
editor.config.define('list.properties', {
|
|
3030
|
-
styles: true,
|
|
3031
|
-
startIndex: false,
|
|
3032
|
-
reversed: false
|
|
3033
|
-
});
|
|
3034
|
-
}
|
|
3035
3131
|
}
|
|
3036
3132
|
/**
|
|
3037
3133
|
* Creates an array of strategies for dealing with enabled listItem attributes.
|
|
@@ -3157,10 +3253,109 @@ class ListPropertiesEditing extends Plugin {
|
|
|
3157
3253
|
return strategies;
|
|
3158
3254
|
}
|
|
3159
3255
|
|
|
3160
|
-
|
|
3256
|
+
/**
|
|
3257
|
+
* The list properties view to be displayed in the list dropdown.
|
|
3258
|
+
*
|
|
3259
|
+
* Contains a grid of available list styles and, for numbered list, also the list start index and reversed fields.
|
|
3260
|
+
*
|
|
3261
|
+
* @internal
|
|
3262
|
+
*/ class ListPropertiesView extends View {
|
|
3263
|
+
/**
|
|
3264
|
+
* A collection of the child views.
|
|
3265
|
+
*/ children;
|
|
3266
|
+
/**
|
|
3267
|
+
* A view that renders the grid of list styles.
|
|
3268
|
+
*/ stylesView = null;
|
|
3269
|
+
/**
|
|
3270
|
+
* A collapsible view that hosts additional list property fields ({@link #startIndexFieldView} and
|
|
3271
|
+
* {@link #reversedSwitchButtonView}) to visually separate them from the {@link #stylesView grid of styles}.
|
|
3272
|
+
*
|
|
3273
|
+
* **Note**: Only present when:
|
|
3274
|
+
* * the view represents **numbered** list properties,
|
|
3275
|
+
* * and the {@link #stylesView} is rendered,
|
|
3276
|
+
* * and either {@link #startIndexFieldView} or {@link #reversedSwitchButtonView} is rendered.
|
|
3277
|
+
*
|
|
3278
|
+
* @readonly
|
|
3279
|
+
*/ additionalPropertiesCollapsibleView = null;
|
|
3280
|
+
/**
|
|
3281
|
+
* A labeled number field allowing the user to set the start index of the list.
|
|
3282
|
+
*
|
|
3283
|
+
* **Note**: Only present when the view represents **numbered** list properties.
|
|
3284
|
+
*
|
|
3285
|
+
* @readonly
|
|
3286
|
+
*/ startIndexFieldView = null;
|
|
3287
|
+
/**
|
|
3288
|
+
* A switch button allowing the user to make the edited list reversed.
|
|
3289
|
+
*
|
|
3290
|
+
* **Note**: Only present when the view represents **numbered** list properties.
|
|
3291
|
+
*
|
|
3292
|
+
* @readonly
|
|
3293
|
+
*/ reversedSwitchButtonView = null;
|
|
3294
|
+
/**
|
|
3295
|
+
* Tracks information about the DOM focus in the view.
|
|
3296
|
+
*/ focusTracker = new FocusTracker();
|
|
3297
|
+
/**
|
|
3298
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
3299
|
+
*/ keystrokes = new KeystrokeHandler();
|
|
3300
|
+
/**
|
|
3301
|
+
* A collection of views that can be focused in the properties view.
|
|
3302
|
+
*/ focusables = new ViewCollection();
|
|
3303
|
+
/**
|
|
3304
|
+
* Helps cycling over {@link #focusables} in the view.
|
|
3305
|
+
*/ focusCycler;
|
|
3306
|
+
/**
|
|
3307
|
+
* Creates an instance of the list properties view.
|
|
3308
|
+
*
|
|
3309
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
3310
|
+
* @param options Options of the view.
|
|
3311
|
+
* @param options.enabledProperties An object containing the configuration of enabled list property names.
|
|
3312
|
+
* Allows conditional rendering the sub-components of the properties view.
|
|
3313
|
+
* @param options.styleButtonViews A list of style buttons to be rendered
|
|
3314
|
+
* inside the styles grid. The grid will not be rendered when `enabledProperties` does not include the `'styles'` key.
|
|
3315
|
+
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
3316
|
+
*/ constructor(locale, { enabledProperties, styleButtonViews, styleGridAriaLabel }){
|
|
3317
|
+
super(locale);
|
|
3318
|
+
const elementCssClasses = [
|
|
3319
|
+
'ck',
|
|
3320
|
+
'ck-list-properties'
|
|
3321
|
+
];
|
|
3322
|
+
this.children = this.createCollection();
|
|
3323
|
+
this.focusCycler = new FocusCycler({
|
|
3324
|
+
focusables: this.focusables,
|
|
3325
|
+
focusTracker: this.focusTracker,
|
|
3326
|
+
keystrokeHandler: this.keystrokes,
|
|
3327
|
+
actions: {
|
|
3328
|
+
// Navigate #children backwards using the <kbd>Shift</kbd> + <kbd>Tab</kbd> keystroke.
|
|
3329
|
+
focusPrevious: 'shift + tab',
|
|
3330
|
+
// Navigate #children forwards using the <kbd>Tab</kbd> key.
|
|
3331
|
+
focusNext: 'tab'
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
// The rendering of the styles grid is conditional. When there is no styles grid, the view will render without collapsible
|
|
3335
|
+
// for numbered list properties, hence simplifying the layout.
|
|
3336
|
+
if (enabledProperties.styles) {
|
|
3337
|
+
this.stylesView = this._createStylesView(styleButtonViews, styleGridAriaLabel);
|
|
3338
|
+
this.children.add(this.stylesView);
|
|
3339
|
+
} else {
|
|
3340
|
+
elementCssClasses.push('ck-list-properties_without-styles');
|
|
3341
|
+
}
|
|
3342
|
+
// The rendering of the numbered list property views is also conditional. It only makes sense for the numbered list
|
|
3343
|
+
// dropdown. The unordered list does not have such properties.
|
|
3344
|
+
if (enabledProperties.startIndex || enabledProperties.reversed) {
|
|
3345
|
+
this._addNumberedListPropertyViews(enabledProperties);
|
|
3346
|
+
elementCssClasses.push('ck-list-properties_with-numbered-properties');
|
|
3347
|
+
}
|
|
3348
|
+
this.setTemplate({
|
|
3349
|
+
tag: 'div',
|
|
3350
|
+
attributes: {
|
|
3351
|
+
class: elementCssClasses
|
|
3352
|
+
},
|
|
3353
|
+
children: this.children
|
|
3354
|
+
});
|
|
3355
|
+
}
|
|
3161
3356
|
/**
|
|
3162
|
-
|
|
3163
|
-
|
|
3357
|
+
* @inheritDoc
|
|
3358
|
+
*/ render() {
|
|
3164
3359
|
super.render();
|
|
3165
3360
|
if (this.stylesView) {
|
|
3166
3361
|
this.focusables.add(this.stylesView);
|
|
@@ -3203,28 +3398,28 @@ class ListPropertiesView extends View {
|
|
|
3203
3398
|
this.keystrokes.listenTo(this.element);
|
|
3204
3399
|
}
|
|
3205
3400
|
/**
|
|
3206
|
-
|
|
3207
|
-
|
|
3401
|
+
* @inheritDoc
|
|
3402
|
+
*/ focus() {
|
|
3208
3403
|
this.focusCycler.focusFirst();
|
|
3209
3404
|
}
|
|
3210
3405
|
/**
|
|
3211
|
-
|
|
3212
|
-
|
|
3406
|
+
* @inheritDoc
|
|
3407
|
+
*/ focusLast() {
|
|
3213
3408
|
this.focusCycler.focusLast();
|
|
3214
3409
|
}
|
|
3215
3410
|
/**
|
|
3216
|
-
|
|
3217
|
-
|
|
3411
|
+
* @inheritDoc
|
|
3412
|
+
*/ destroy() {
|
|
3218
3413
|
super.destroy();
|
|
3219
3414
|
this.focusTracker.destroy();
|
|
3220
3415
|
this.keystrokes.destroy();
|
|
3221
3416
|
}
|
|
3222
3417
|
/**
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3418
|
+
* Creates the list styles grid.
|
|
3419
|
+
*
|
|
3420
|
+
* @param styleButtons Buttons to be placed in the grid.
|
|
3421
|
+
* @param styleGridAriaLabel The assistive technology label of the grid.
|
|
3422
|
+
*/ _createStylesView(styleButtons, styleGridAriaLabel) {
|
|
3228
3423
|
const stylesView = new View(this.locale);
|
|
3229
3424
|
stylesView.children = stylesView.createCollection();
|
|
3230
3425
|
stylesView.children.addMany(styleButtons);
|
|
@@ -3250,11 +3445,11 @@ class ListPropertiesView extends View {
|
|
|
3250
3445
|
return stylesView;
|
|
3251
3446
|
}
|
|
3252
3447
|
/**
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3448
|
+
* Renders {@link #startIndexFieldView} and/or {@link #reversedSwitchButtonView} depending on the configuration of the properties view.
|
|
3449
|
+
*
|
|
3450
|
+
* @param enabledProperties An object containing the configuration of enabled list property names
|
|
3451
|
+
* (see {@link #constructor}).
|
|
3452
|
+
*/ _addNumberedListPropertyViews(enabledProperties) {
|
|
3258
3453
|
const t = this.locale.t;
|
|
3259
3454
|
const numberedPropertyViews = [];
|
|
3260
3455
|
if (enabledProperties.startIndex) {
|
|
@@ -3286,8 +3481,8 @@ class ListPropertiesView extends View {
|
|
|
3286
3481
|
}
|
|
3287
3482
|
}
|
|
3288
3483
|
/**
|
|
3289
|
-
|
|
3290
|
-
|
|
3484
|
+
* Creates the list start index labeled field.
|
|
3485
|
+
*/ _createStartIndexField() {
|
|
3291
3486
|
const t = this.locale.t;
|
|
3292
3487
|
const startIndexFieldView = new LabeledFieldView(this.locale, createLabeledInputNumber);
|
|
3293
3488
|
startIndexFieldView.set({
|
|
@@ -3320,8 +3515,8 @@ class ListPropertiesView extends View {
|
|
|
3320
3515
|
return startIndexFieldView;
|
|
3321
3516
|
}
|
|
3322
3517
|
/**
|
|
3323
|
-
|
|
3324
|
-
|
|
3518
|
+
* Creates the reversed list switch button.
|
|
3519
|
+
*/ _createReversedSwitchButton() {
|
|
3325
3520
|
const t = this.locale.t;
|
|
3326
3521
|
const reversedButtonView = new SwitchButtonView(this.locale);
|
|
3327
3522
|
reversedButtonView.set({
|
|
@@ -3332,93 +3527,6 @@ class ListPropertiesView extends View {
|
|
|
3332
3527
|
reversedButtonView.delegate('execute').to(this, 'listReversed');
|
|
3333
3528
|
return reversedButtonView;
|
|
3334
3529
|
}
|
|
3335
|
-
/**
|
|
3336
|
-
* Creates an instance of the list properties view.
|
|
3337
|
-
*
|
|
3338
|
-
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
3339
|
-
* @param options Options of the view.
|
|
3340
|
-
* @param options.enabledProperties An object containing the configuration of enabled list property names.
|
|
3341
|
-
* Allows conditional rendering the sub-components of the properties view.
|
|
3342
|
-
* @param options.styleButtonViews A list of style buttons to be rendered
|
|
3343
|
-
* inside the styles grid. The grid will not be rendered when `enabledProperties` does not include the `'styles'` key.
|
|
3344
|
-
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
3345
|
-
*/ constructor(locale, { enabledProperties, styleButtonViews, styleGridAriaLabel }){
|
|
3346
|
-
super(locale);
|
|
3347
|
-
/**
|
|
3348
|
-
* A view that renders the grid of list styles.
|
|
3349
|
-
*/ this.stylesView = null;
|
|
3350
|
-
/**
|
|
3351
|
-
* A collapsible view that hosts additional list property fields ({@link #startIndexFieldView} and
|
|
3352
|
-
* {@link #reversedSwitchButtonView}) to visually separate them from the {@link #stylesView grid of styles}.
|
|
3353
|
-
*
|
|
3354
|
-
* **Note**: Only present when:
|
|
3355
|
-
* * the view represents **numbered** list properties,
|
|
3356
|
-
* * and the {@link #stylesView} is rendered,
|
|
3357
|
-
* * and either {@link #startIndexFieldView} or {@link #reversedSwitchButtonView} is rendered.
|
|
3358
|
-
*
|
|
3359
|
-
* @readonly
|
|
3360
|
-
*/ this.additionalPropertiesCollapsibleView = null;
|
|
3361
|
-
/**
|
|
3362
|
-
* A labeled number field allowing the user to set the start index of the list.
|
|
3363
|
-
*
|
|
3364
|
-
* **Note**: Only present when the view represents **numbered** list properties.
|
|
3365
|
-
*
|
|
3366
|
-
* @readonly
|
|
3367
|
-
*/ this.startIndexFieldView = null;
|
|
3368
|
-
/**
|
|
3369
|
-
* A switch button allowing the user to make the edited list reversed.
|
|
3370
|
-
*
|
|
3371
|
-
* **Note**: Only present when the view represents **numbered** list properties.
|
|
3372
|
-
*
|
|
3373
|
-
* @readonly
|
|
3374
|
-
*/ this.reversedSwitchButtonView = null;
|
|
3375
|
-
/**
|
|
3376
|
-
* Tracks information about the DOM focus in the view.
|
|
3377
|
-
*/ this.focusTracker = new FocusTracker();
|
|
3378
|
-
/**
|
|
3379
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
3380
|
-
*/ this.keystrokes = new KeystrokeHandler();
|
|
3381
|
-
/**
|
|
3382
|
-
* A collection of views that can be focused in the properties view.
|
|
3383
|
-
*/ this.focusables = new ViewCollection();
|
|
3384
|
-
const elementCssClasses = [
|
|
3385
|
-
'ck',
|
|
3386
|
-
'ck-list-properties'
|
|
3387
|
-
];
|
|
3388
|
-
this.children = this.createCollection();
|
|
3389
|
-
this.focusCycler = new FocusCycler({
|
|
3390
|
-
focusables: this.focusables,
|
|
3391
|
-
focusTracker: this.focusTracker,
|
|
3392
|
-
keystrokeHandler: this.keystrokes,
|
|
3393
|
-
actions: {
|
|
3394
|
-
// Navigate #children backwards using the <kbd>Shift</kbd> + <kbd>Tab</kbd> keystroke.
|
|
3395
|
-
focusPrevious: 'shift + tab',
|
|
3396
|
-
// Navigate #children forwards using the <kbd>Tab</kbd> key.
|
|
3397
|
-
focusNext: 'tab'
|
|
3398
|
-
}
|
|
3399
|
-
});
|
|
3400
|
-
// The rendering of the styles grid is conditional. When there is no styles grid, the view will render without collapsible
|
|
3401
|
-
// for numbered list properties, hence simplifying the layout.
|
|
3402
|
-
if (enabledProperties.styles) {
|
|
3403
|
-
this.stylesView = this._createStylesView(styleButtonViews, styleGridAriaLabel);
|
|
3404
|
-
this.children.add(this.stylesView);
|
|
3405
|
-
} else {
|
|
3406
|
-
elementCssClasses.push('ck-list-properties_without-styles');
|
|
3407
|
-
}
|
|
3408
|
-
// The rendering of the numbered list property views is also conditional. It only makes sense for the numbered list
|
|
3409
|
-
// dropdown. The unordered list does not have such properties.
|
|
3410
|
-
if (enabledProperties.startIndex || enabledProperties.reversed) {
|
|
3411
|
-
this._addNumberedListPropertyViews(enabledProperties);
|
|
3412
|
-
elementCssClasses.push('ck-list-properties_with-numbered-properties');
|
|
3413
|
-
}
|
|
3414
|
-
this.setTemplate({
|
|
3415
|
-
tag: 'div',
|
|
3416
|
-
attributes: {
|
|
3417
|
-
class: elementCssClasses
|
|
3418
|
-
},
|
|
3419
|
-
children: this.children
|
|
3420
|
-
});
|
|
3421
|
-
}
|
|
3422
3530
|
}
|
|
3423
3531
|
|
|
3424
3532
|
var listStyleDiscIcon = "<svg viewBox=\"0 0 44 44\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z\" fill-opacity=\".163\"/><path d=\"M11 27a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6z\"/></svg>";
|
|
@@ -3439,10 +3547,16 @@ var listStyleLowerLatinIcon = "<svg viewBox=\"0 0 44 44\" xmlns=\"http://www.w3.
|
|
|
3439
3547
|
|
|
3440
3548
|
var listStyleUpperLatinIcon = "<svg viewBox=\"0 0 44 44\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z\" fill-opacity=\".163\"/><path d=\"m7.88 15 .532-1.463h2.575L11.549 15h1.415l-2.58-6.442H9.01L6.5 15h1.38zm2.69-2.549H8.811l.87-2.39.887 2.39zM14.88 15v-1.235h-1.234V15h1.234zM9.352 25c.83-.006 1.352-.02 1.569-.044.346-.038.636-.14.872-.305.236-.166.422-.387.558-.664.137-.277.205-.562.205-.855 0-.372-.106-.695-.317-.97-.21-.276-.512-.471-.905-.585a1.51 1.51 0 0 0 .661-.567 1.5 1.5 0 0 0 .244-.83c0-.28-.066-.53-.197-.754a1.654 1.654 0 0 0-.495-.539 1.676 1.676 0 0 0-.672-.266c-.25-.042-.63-.063-1.14-.063H7.158V25h2.193zm.142-3.88H8.46v-1.49h.747c.612 0 .983.007 1.112.022.217.026.38.102.49.226.11.125.165.287.165.486a.68.68 0 0 1-.192.503.86.86 0 0 1-.525.23 11.47 11.47 0 0 1-.944.023h.18zm.17 2.795H8.46v-1.723h1.05c.592 0 .977.03 1.154.092.177.062.313.16.406.295a.84.84 0 0 1 .14.492c0 .228-.06.41-.181.547a.806.806 0 0 1-.473.257c-.126.026-.423.04-.892.04zM14.88 25v-1.235h-1.234V25h1.234zm-5.018 9.11c.691 0 1.262-.17 1.711-.512.45-.341.772-.864.965-1.567l-1.261-.4c-.109.472-.287.818-.536 1.037-.25.22-.547.33-.892.33-.47 0-.85-.173-1.143-.519-.293-.345-.44-.925-.44-1.74 0-.767.15-1.322.447-1.665.297-.343.684-.514 1.162-.514.346 0 .64.096.881.29.242.193.4.457.477.79l1.288-.307c-.147-.516-.367-.911-.66-1.187-.492-.465-1.132-.698-1.92-.698-.902 0-1.63.296-2.184.89-.554.593-.83 1.426-.83 2.498 0 1.014.275 1.813.825 2.397.551.585 1.254.877 2.11.877zM14.88 34v-1.235h-1.234V34h1.234z\"/></svg>";
|
|
3441
3549
|
|
|
3442
|
-
|
|
3550
|
+
/**
|
|
3551
|
+
* The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
3552
|
+
* buttons that allow users to control such aspects of list as the marker, start index or order.
|
|
3553
|
+
*
|
|
3554
|
+
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
3555
|
+
* (because they share the same names).
|
|
3556
|
+
*/ class ListPropertiesUI extends Plugin {
|
|
3443
3557
|
/**
|
|
3444
|
-
|
|
3445
|
-
|
|
3558
|
+
* @inheritDoc
|
|
3559
|
+
*/ static get pluginName() {
|
|
3446
3560
|
return 'ListPropertiesUI';
|
|
3447
3561
|
}
|
|
3448
3562
|
init() {
|
|
@@ -3774,37 +3888,60 @@ function getStyleTypeSupportChecker(listStyleCommand) {
|
|
|
3774
3888
|
}
|
|
3775
3889
|
}
|
|
3776
3890
|
|
|
3777
|
-
|
|
3891
|
+
/**
|
|
3892
|
+
* The list properties feature.
|
|
3893
|
+
*
|
|
3894
|
+
* This is a "glue" plugin that loads the
|
|
3895
|
+
* {@link module:list/listproperties/listpropertiesediting~ListPropertiesEditing list properties
|
|
3896
|
+
* editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
3897
|
+
*/ class ListProperties extends Plugin {
|
|
3778
3898
|
/**
|
|
3779
|
-
|
|
3780
|
-
|
|
3899
|
+
* @inheritDoc
|
|
3900
|
+
*/ static get requires() {
|
|
3781
3901
|
return [
|
|
3782
3902
|
ListPropertiesEditing,
|
|
3783
3903
|
ListPropertiesUI
|
|
3784
3904
|
];
|
|
3785
3905
|
}
|
|
3786
3906
|
/**
|
|
3787
|
-
|
|
3788
|
-
|
|
3907
|
+
* @inheritDoc
|
|
3908
|
+
*/ static get pluginName() {
|
|
3789
3909
|
return 'ListProperties';
|
|
3790
3910
|
}
|
|
3791
3911
|
}
|
|
3792
3912
|
|
|
3793
|
-
|
|
3913
|
+
/**
|
|
3914
|
+
* The check to-do command.
|
|
3915
|
+
*
|
|
3916
|
+
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
3917
|
+
* the `checkTodoList` editor command.
|
|
3918
|
+
*/ class CheckTodoListCommand extends Command {
|
|
3919
|
+
/**
|
|
3920
|
+
* @inheritDoc
|
|
3921
|
+
*/ constructor(editor){
|
|
3922
|
+
super(editor);
|
|
3923
|
+
// Refresh command before executing to be sure all values are up to date.
|
|
3924
|
+
// It is needed when selection has changed before command execution, in the same change block.
|
|
3925
|
+
this.on('execute', ()=>{
|
|
3926
|
+
this.refresh();
|
|
3927
|
+
}, {
|
|
3928
|
+
priority: 'highest'
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3794
3931
|
/**
|
|
3795
|
-
|
|
3796
|
-
|
|
3932
|
+
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
3933
|
+
*/ refresh() {
|
|
3797
3934
|
const selectedElements = this._getSelectedItems();
|
|
3798
3935
|
this.value = this._getValue(selectedElements);
|
|
3799
3936
|
this.isEnabled = !!selectedElements.length;
|
|
3800
3937
|
}
|
|
3801
3938
|
/**
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3939
|
+
* Executes the command.
|
|
3940
|
+
*
|
|
3941
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
3942
|
+
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
3943
|
+
* value to decide what it should do.
|
|
3944
|
+
*/ execute(options = {}) {
|
|
3808
3945
|
this.editor.model.change((writer)=>{
|
|
3809
3946
|
const selectedElements = this._getSelectedItems();
|
|
3810
3947
|
const value = options.forceValue === undefined ? !this._getValue(selectedElements) : options.forceValue;
|
|
@@ -3818,13 +3955,13 @@ class CheckTodoListCommand extends Command {
|
|
|
3818
3955
|
});
|
|
3819
3956
|
}
|
|
3820
3957
|
/**
|
|
3821
|
-
|
|
3822
|
-
|
|
3958
|
+
* Returns a value for the command.
|
|
3959
|
+
*/ _getValue(selectedElements) {
|
|
3823
3960
|
return selectedElements.every((element)=>element.getAttribute('todoListChecked'));
|
|
3824
3961
|
}
|
|
3825
3962
|
/**
|
|
3826
|
-
|
|
3827
|
-
|
|
3963
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
3964
|
+
*/ _getSelectedItems() {
|
|
3828
3965
|
const model = this.editor.model;
|
|
3829
3966
|
const schema = model.schema;
|
|
3830
3967
|
const selectionRange = model.document.selection.getFirstRange();
|
|
@@ -3842,24 +3979,22 @@ class CheckTodoListCommand extends Command {
|
|
|
3842
3979
|
}
|
|
3843
3980
|
return elements;
|
|
3844
3981
|
}
|
|
3845
|
-
/**
|
|
3846
|
-
* @inheritDoc
|
|
3847
|
-
*/ constructor(editor){
|
|
3848
|
-
super(editor);
|
|
3849
|
-
// Refresh command before executing to be sure all values are up to date.
|
|
3850
|
-
// It is needed when selection has changed before command execution, in the same change block.
|
|
3851
|
-
this.on('execute', ()=>{
|
|
3852
|
-
this.refresh();
|
|
3853
|
-
}, {
|
|
3854
|
-
priority: 'highest'
|
|
3855
|
-
});
|
|
3856
|
-
}
|
|
3857
3982
|
}
|
|
3858
3983
|
|
|
3859
|
-
|
|
3984
|
+
/**
|
|
3985
|
+
* Observes all to-do list checkboxes state changes.
|
|
3986
|
+
*
|
|
3987
|
+
* Note that this observer is not available by default. To make it available it needs to be added to
|
|
3988
|
+
* {@link module:engine/view/view~View} by {@link module:engine/view/view~View#addObserver} method.
|
|
3989
|
+
*/ class TodoCheckboxChangeObserver extends DomEventObserver {
|
|
3990
|
+
/**
|
|
3991
|
+
* @inheritDoc
|
|
3992
|
+
*/ domEventType = [
|
|
3993
|
+
'change'
|
|
3994
|
+
];
|
|
3860
3995
|
/**
|
|
3861
|
-
|
|
3862
|
-
|
|
3996
|
+
* @inheritDoc
|
|
3997
|
+
*/ onDomEvent(domEvent) {
|
|
3863
3998
|
if (domEvent.target) {
|
|
3864
3999
|
const viewTarget = this.view.domConverter.mapDomToView(domEvent.target);
|
|
3865
4000
|
if (viewTarget && viewTarget.is('element', 'input') && viewTarget.getAttribute('type') == 'checkbox' && viewTarget.findAncestor({
|
|
@@ -3869,33 +4004,33 @@ class TodoCheckboxChangeObserver extends DomEventObserver {
|
|
|
3869
4004
|
}
|
|
3870
4005
|
}
|
|
3871
4006
|
}
|
|
3872
|
-
constructor(){
|
|
3873
|
-
super(...arguments);
|
|
3874
|
-
/**
|
|
3875
|
-
* @inheritDoc
|
|
3876
|
-
*/ this.domEventType = [
|
|
3877
|
-
'change'
|
|
3878
|
-
];
|
|
3879
|
-
}
|
|
3880
4007
|
}
|
|
3881
4008
|
|
|
3882
|
-
const ITEM_TOGGLE_KEYSTROKE$1 = parseKeystroke('Ctrl+Enter');
|
|
3883
|
-
|
|
4009
|
+
const ITEM_TOGGLE_KEYSTROKE$1 = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
4010
|
+
/**
|
|
4011
|
+
* The engine of the to-do list feature. It handles creating, editing and removing to-do lists and their items.
|
|
4012
|
+
*
|
|
4013
|
+
* It registers the entire functionality of the {@link module:list/list/listediting~ListEditing list editing plugin}
|
|
4014
|
+
* and extends it with the commands:
|
|
4015
|
+
*
|
|
4016
|
+
* - `'todoList'`,
|
|
4017
|
+
* - `'checkTodoList'`,
|
|
4018
|
+
*/ class TodoListEditing extends Plugin {
|
|
3884
4019
|
/**
|
|
3885
|
-
|
|
3886
|
-
|
|
4020
|
+
* @inheritDoc
|
|
4021
|
+
*/ static get pluginName() {
|
|
3887
4022
|
return 'TodoListEditing';
|
|
3888
4023
|
}
|
|
3889
4024
|
/**
|
|
3890
|
-
|
|
3891
|
-
|
|
4025
|
+
* @inheritDoc
|
|
4026
|
+
*/ static get requires() {
|
|
3892
4027
|
return [
|
|
3893
4028
|
ListEditing
|
|
3894
4029
|
];
|
|
3895
4030
|
}
|
|
3896
4031
|
/**
|
|
3897
|
-
|
|
3898
|
-
|
|
4032
|
+
* @inheritDoc
|
|
4033
|
+
*/ init() {
|
|
3899
4034
|
const editor = this.editor;
|
|
3900
4035
|
const model = editor.model;
|
|
3901
4036
|
const editing = editor.editing;
|
|
@@ -4132,13 +4267,13 @@ class TodoListEditing extends Plugin {
|
|
|
4132
4267
|
this._initAriaAnnouncements();
|
|
4133
4268
|
}
|
|
4134
4269
|
/**
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4270
|
+
* Handles the checkbox element change, moves the selection to the corresponding model item to make it possible
|
|
4271
|
+
* to toggle the `todoListChecked` attribute using the command, and restores the selection position.
|
|
4272
|
+
*
|
|
4273
|
+
* Some say it's a hack :) Moving the selection only for executing the command on a certain node and restoring it after,
|
|
4274
|
+
* is not a clear solution. We need to design an API for using commands beyond the selection range.
|
|
4275
|
+
* See https://github.com/ckeditor/ckeditor5/issues/1954.
|
|
4276
|
+
*/ _handleCheckmarkChange(listItem) {
|
|
4142
4277
|
const editor = this.editor;
|
|
4143
4278
|
const model = editor.model;
|
|
4144
4279
|
const previousSelectionRanges = Array.from(model.document.selection.getRanges());
|
|
@@ -4149,11 +4284,11 @@ class TodoListEditing extends Plugin {
|
|
|
4149
4284
|
});
|
|
4150
4285
|
}
|
|
4151
4286
|
/**
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4287
|
+
* Observe when user enters or leaves todo list and set proper aria value in global live announcer.
|
|
4288
|
+
* This allows screen readers to indicate when the user has entered and left the specified todo list.
|
|
4289
|
+
*
|
|
4290
|
+
* @internal
|
|
4291
|
+
*/ _initAriaAnnouncements() {
|
|
4157
4292
|
const { model, ui, t } = this.editor;
|
|
4158
4293
|
let lastFocusedCodeBlock = null;
|
|
4159
4294
|
if (!ui) {
|
|
@@ -4300,52 +4435,74 @@ class TodoListEditing extends Plugin {
|
|
|
4300
4435
|
return element.getAttribute('listType') == 'todo';
|
|
4301
4436
|
}
|
|
4302
4437
|
|
|
4303
|
-
|
|
4438
|
+
/**
|
|
4439
|
+
* The to-do list UI feature. It introduces the `'todoList'` button that
|
|
4440
|
+
* allows to convert elements to and from to-do list items and to indent or outdent them.
|
|
4441
|
+
*/ class TodoListUI extends Plugin {
|
|
4304
4442
|
/**
|
|
4305
|
-
|
|
4306
|
-
|
|
4443
|
+
* @inheritDoc
|
|
4444
|
+
*/ static get pluginName() {
|
|
4307
4445
|
return 'TodoListUI';
|
|
4308
4446
|
}
|
|
4309
4447
|
/**
|
|
4310
|
-
|
|
4311
|
-
|
|
4448
|
+
* @inheritDoc
|
|
4449
|
+
*/ init() {
|
|
4312
4450
|
const t = this.editor.t;
|
|
4313
4451
|
createUIComponents(this.editor, 'todoList', t('To-do List'), icons.todoList);
|
|
4314
4452
|
}
|
|
4315
4453
|
}
|
|
4316
4454
|
|
|
4317
|
-
|
|
4455
|
+
/**
|
|
4456
|
+
* The to-do list feature.
|
|
4457
|
+
*
|
|
4458
|
+
* This is a "glue" plugin that loads the {@link module:list/todolist/todolistediting~TodoListEditing to-do list
|
|
4459
|
+
* editing feature} and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
4460
|
+
*/ class TodoList extends Plugin {
|
|
4318
4461
|
/**
|
|
4319
|
-
|
|
4320
|
-
|
|
4462
|
+
* @inheritDoc
|
|
4463
|
+
*/ static get requires() {
|
|
4321
4464
|
return [
|
|
4322
4465
|
TodoListEditing,
|
|
4323
4466
|
TodoListUI
|
|
4324
4467
|
];
|
|
4325
4468
|
}
|
|
4326
4469
|
/**
|
|
4327
|
-
|
|
4328
|
-
|
|
4470
|
+
* @inheritDoc
|
|
4471
|
+
*/ static get pluginName() {
|
|
4329
4472
|
return 'TodoList';
|
|
4330
4473
|
}
|
|
4331
4474
|
}
|
|
4332
4475
|
|
|
4333
|
-
|
|
4476
|
+
/**
|
|
4477
|
+
* The list command. It is used by the {@link module:list/legacylist~LegacyList legacy list feature}.
|
|
4478
|
+
*/ class LegacyListCommand extends Command {
|
|
4479
|
+
/**
|
|
4480
|
+
* The type of the list created by the command.
|
|
4481
|
+
*/ type;
|
|
4334
4482
|
/**
|
|
4335
|
-
|
|
4336
|
-
|
|
4483
|
+
* Creates an instance of the command.
|
|
4484
|
+
*
|
|
4485
|
+
* @param editor The editor instance.
|
|
4486
|
+
* @param type List type that will be handled by this command.
|
|
4487
|
+
*/ constructor(editor, type){
|
|
4488
|
+
super(editor);
|
|
4489
|
+
this.type = type;
|
|
4490
|
+
}
|
|
4491
|
+
/**
|
|
4492
|
+
* @inheritDoc
|
|
4493
|
+
*/ refresh() {
|
|
4337
4494
|
this.value = this._getValue();
|
|
4338
4495
|
this.isEnabled = this._checkEnabled();
|
|
4339
4496
|
}
|
|
4340
4497
|
/**
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4498
|
+
* Executes the list command.
|
|
4499
|
+
*
|
|
4500
|
+
* @fires execute
|
|
4501
|
+
* @param options Command options.
|
|
4502
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
4503
|
+
* selected items and potentially the neighbor elements to the proper list items. If set to `false`, it will convert selected elements
|
|
4504
|
+
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
4505
|
+
*/ execute(options = {}) {
|
|
4349
4506
|
const model = this.editor.model;
|
|
4350
4507
|
const document = model.document;
|
|
4351
4508
|
const blocks = Array.from(document.selection.getSelectedBlocks()).filter((block)=>checkCanBecomeListItem(block, model.schema));
|
|
@@ -4492,30 +4649,30 @@ class LegacyListCommand extends Command {
|
|
|
4492
4649
|
}
|
|
4493
4650
|
}
|
|
4494
4651
|
/**
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4652
|
+
* Event fired by the {@link #execute} method.
|
|
4653
|
+
*
|
|
4654
|
+
* It allows to execute an action after executing the {@link ~ListCommand#execute} method, for example adjusting
|
|
4655
|
+
* attributes of changed blocks.
|
|
4656
|
+
*
|
|
4657
|
+
* @protected
|
|
4658
|
+
* @event _executeCleanup
|
|
4659
|
+
*/ this.fire('_executeCleanup', blocks);
|
|
4503
4660
|
});
|
|
4504
4661
|
}
|
|
4505
4662
|
/**
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4663
|
+
* Checks the command's {@link #value}.
|
|
4664
|
+
*
|
|
4665
|
+
* @returns The current value.
|
|
4666
|
+
*/ _getValue() {
|
|
4510
4667
|
// Check whether closest `listItem` ancestor of the position has a correct type.
|
|
4511
4668
|
const listItem = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
4512
4669
|
return !!listItem && listItem.is('element', 'listItem') && listItem.getAttribute('listType') == this.type;
|
|
4513
4670
|
}
|
|
4514
4671
|
/**
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4672
|
+
* Checks whether the command can be enabled in the current context.
|
|
4673
|
+
*
|
|
4674
|
+
* @returns Whether the command should be enabled.
|
|
4675
|
+
*/ _checkEnabled() {
|
|
4519
4676
|
// If command value is true it means that we are in list item, so the command should be enabled.
|
|
4520
4677
|
if (this.value) {
|
|
4521
4678
|
return true;
|
|
@@ -4529,15 +4686,6 @@ class LegacyListCommand extends Command {
|
|
|
4529
4686
|
// Otherwise, check if list item can be inserted at the position start.
|
|
4530
4687
|
return checkCanBecomeListItem(firstBlock, schema);
|
|
4531
4688
|
}
|
|
4532
|
-
/**
|
|
4533
|
-
* Creates an instance of the command.
|
|
4534
|
-
*
|
|
4535
|
-
* @param editor The editor instance.
|
|
4536
|
-
* @param type List type that will be handled by this command.
|
|
4537
|
-
*/ constructor(editor, type){
|
|
4538
|
-
super(editor);
|
|
4539
|
-
this.type = type;
|
|
4540
|
-
}
|
|
4541
4689
|
}
|
|
4542
4690
|
/**
|
|
4543
4691
|
* Helper function used when one or more list item have their type changed. Fixes type of other list items
|
|
@@ -4591,17 +4739,31 @@ class LegacyListCommand extends Command {
|
|
|
4591
4739
|
return schema.checkChild(block.parent, 'listItem') && !schema.isObject(block);
|
|
4592
4740
|
}
|
|
4593
4741
|
|
|
4594
|
-
|
|
4742
|
+
/**
|
|
4743
|
+
* The list indent command. It is used by the {@link module:list/legacylist~LegacyList legacy list feature}.
|
|
4744
|
+
*/ class LegacyIndentCommand extends Command {
|
|
4745
|
+
/**
|
|
4746
|
+
* Determines by how much the command will change the list item's indent attribute.
|
|
4747
|
+
*/ _indentBy;
|
|
4595
4748
|
/**
|
|
4596
|
-
|
|
4597
|
-
|
|
4749
|
+
* Creates an instance of the command.
|
|
4750
|
+
*
|
|
4751
|
+
* @param editor The editor instance.
|
|
4752
|
+
* @param indentDirection The direction of indent. If it is equal to `backward`, the command will outdent a list item.
|
|
4753
|
+
*/ constructor(editor, indentDirection){
|
|
4754
|
+
super(editor);
|
|
4755
|
+
this._indentBy = indentDirection == 'forward' ? 1 : -1;
|
|
4756
|
+
}
|
|
4757
|
+
/**
|
|
4758
|
+
* @inheritDoc
|
|
4759
|
+
*/ refresh() {
|
|
4598
4760
|
this.isEnabled = this._checkEnabled();
|
|
4599
4761
|
}
|
|
4600
4762
|
/**
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4763
|
+
* Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
|
|
4764
|
+
*
|
|
4765
|
+
* @fires execute
|
|
4766
|
+
*/ execute() {
|
|
4605
4767
|
const model = this.editor.model;
|
|
4606
4768
|
const doc = model.document;
|
|
4607
4769
|
let itemsToChange = Array.from(doc.selection.getSelectedBlocks());
|
|
@@ -4640,10 +4802,10 @@ class LegacyIndentCommand extends Command {
|
|
|
4640
4802
|
});
|
|
4641
4803
|
}
|
|
4642
4804
|
/**
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4805
|
+
* Checks whether the command can be enabled in the current context.
|
|
4806
|
+
*
|
|
4807
|
+
* @returns Whether the command should be enabled.
|
|
4808
|
+
*/ _checkEnabled() {
|
|
4647
4809
|
// Check whether any of position's ancestor is a list item.
|
|
4648
4810
|
const listItem = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
4649
4811
|
// If selection is not in a list item, the command is disabled.
|
|
@@ -4672,15 +4834,6 @@ class LegacyIndentCommand extends Command {
|
|
|
4672
4834
|
// If we are outdenting it is enough to be in list item. Every list item can always be outdented.
|
|
4673
4835
|
return true;
|
|
4674
4836
|
}
|
|
4675
|
-
/**
|
|
4676
|
-
* Creates an instance of the command.
|
|
4677
|
-
*
|
|
4678
|
-
* @param editor The editor instance.
|
|
4679
|
-
* @param indentDirection The direction of indent. If it is equal to `backward`, the command will outdent a list item.
|
|
4680
|
-
*/ constructor(editor, indentDirection){
|
|
4681
|
-
super(editor);
|
|
4682
|
-
this._indentBy = indentDirection == 'forward' ? 1 : -1;
|
|
4683
|
-
}
|
|
4684
4837
|
}
|
|
4685
4838
|
|
|
4686
4839
|
/**
|
|
@@ -5012,36 +5165,38 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5012
5165
|
return getFillerOffset.call(this);
|
|
5013
5166
|
}
|
|
5014
5167
|
|
|
5015
|
-
|
|
5168
|
+
/**
|
|
5169
|
+
* A set of helpers related to legacy lists.
|
|
5170
|
+
*/ class LegacyListUtils extends Plugin {
|
|
5016
5171
|
/**
|
|
5017
|
-
|
|
5018
|
-
|
|
5172
|
+
* @inheritDoc
|
|
5173
|
+
*/ static get pluginName() {
|
|
5019
5174
|
return 'LegacyListUtils';
|
|
5020
5175
|
}
|
|
5021
5176
|
/**
|
|
5022
|
-
|
|
5023
|
-
|
|
5177
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
5178
|
+
*/ getListTypeFromListStyleType(listStyleType) {
|
|
5024
5179
|
return getListTypeFromListStyleType(listStyleType);
|
|
5025
5180
|
}
|
|
5026
5181
|
/**
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5182
|
+
* Returns an array with all `listItem` elements in the model selection.
|
|
5183
|
+
*
|
|
5184
|
+
* It returns all the items even if only a part of the list is selected, including items that belong to nested lists.
|
|
5185
|
+
* If no list is selected, it returns an empty array.
|
|
5186
|
+
* The order of the elements is not specified.
|
|
5187
|
+
*/ getSelectedListItems(model) {
|
|
5033
5188
|
return getSelectedListItems(model);
|
|
5034
5189
|
}
|
|
5035
5190
|
/**
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5191
|
+
* Returns an array with all `listItem` elements that represent the same list.
|
|
5192
|
+
*
|
|
5193
|
+
* It means that values of `listIndent`, `listType`, `listStyle`, `listReversed` and `listStart` for all items are equal.
|
|
5194
|
+
*
|
|
5195
|
+
* Additionally, if the `position` is inside a list item, that list item will be returned as well.
|
|
5196
|
+
*
|
|
5197
|
+
* @param position Starting position.
|
|
5198
|
+
* @param direction Walking direction.
|
|
5199
|
+
*/ getSiblingNodes(position, direction) {
|
|
5045
5200
|
return getSiblingNodes(position, direction);
|
|
5046
5201
|
}
|
|
5047
5202
|
}
|
|
@@ -5913,15 +6068,19 @@ class LegacyListUtils extends Plugin {
|
|
|
5913
6068
|
return indent;
|
|
5914
6069
|
}
|
|
5915
6070
|
|
|
5916
|
-
|
|
6071
|
+
/**
|
|
6072
|
+
* The engine of the list feature. It handles creating, editing and removing lists and list items.
|
|
6073
|
+
*
|
|
6074
|
+
* It registers the `'numberedList'`, `'bulletedList'`, `'indentList'` and `'outdentList'` commands.
|
|
6075
|
+
*/ class LegacyListEditing extends Plugin {
|
|
5917
6076
|
/**
|
|
5918
|
-
|
|
5919
|
-
|
|
6077
|
+
* @inheritDoc
|
|
6078
|
+
*/ static get pluginName() {
|
|
5920
6079
|
return 'LegacyListEditing';
|
|
5921
6080
|
}
|
|
5922
6081
|
/**
|
|
5923
|
-
|
|
5924
|
-
|
|
6082
|
+
* @inheritDoc
|
|
6083
|
+
*/ static get requires() {
|
|
5925
6084
|
return [
|
|
5926
6085
|
Enter,
|
|
5927
6086
|
Delete,
|
|
@@ -5929,8 +6088,8 @@ class LegacyListEditing extends Plugin {
|
|
|
5929
6088
|
];
|
|
5930
6089
|
}
|
|
5931
6090
|
/**
|
|
5932
|
-
|
|
5933
|
-
|
|
6091
|
+
* @inheritDoc
|
|
6092
|
+
*/ init() {
|
|
5934
6093
|
const editor = this.editor;
|
|
5935
6094
|
// Schema.
|
|
5936
6095
|
// Note: in case `$block` will ever be allowed in `listItem`, keep in mind that this feature
|
|
@@ -6054,8 +6213,8 @@ class LegacyListEditing extends Plugin {
|
|
|
6054
6213
|
});
|
|
6055
6214
|
}
|
|
6056
6215
|
/**
|
|
6057
|
-
|
|
6058
|
-
|
|
6216
|
+
* @inheritDoc
|
|
6217
|
+
*/ afterInit() {
|
|
6059
6218
|
const commands = this.editor.commands;
|
|
6060
6219
|
const indent = commands.get('indent');
|
|
6061
6220
|
const outdent = commands.get('outdent');
|
|
@@ -6079,36 +6238,60 @@ function getViewListItemLength(element) {
|
|
|
6079
6238
|
return length;
|
|
6080
6239
|
}
|
|
6081
6240
|
|
|
6082
|
-
|
|
6241
|
+
/**
|
|
6242
|
+
* The legacy list feature.
|
|
6243
|
+
*
|
|
6244
|
+
* This is a "glue" plugin that loads the {@link module:list/legacylist/legacylistediting~LegacyListEditing legacy list editing feature}
|
|
6245
|
+
* and {@link module:list/list/listui~ListUI list UI feature}.
|
|
6246
|
+
*/ class LegacyList extends Plugin {
|
|
6083
6247
|
/**
|
|
6084
|
-
|
|
6085
|
-
|
|
6248
|
+
* @inheritDoc
|
|
6249
|
+
*/ static get requires() {
|
|
6086
6250
|
return [
|
|
6087
6251
|
LegacyListEditing,
|
|
6088
6252
|
ListUI
|
|
6089
6253
|
];
|
|
6090
6254
|
}
|
|
6091
6255
|
/**
|
|
6092
|
-
|
|
6093
|
-
|
|
6256
|
+
* @inheritDoc
|
|
6257
|
+
*/ static get pluginName() {
|
|
6094
6258
|
return 'LegacyList';
|
|
6095
6259
|
}
|
|
6096
6260
|
}
|
|
6097
6261
|
|
|
6098
|
-
|
|
6262
|
+
/**
|
|
6263
|
+
* The list style command. It changes the `listStyle` attribute of the selected list items.
|
|
6264
|
+
*
|
|
6265
|
+
* If the list type (numbered or bulleted) can be inferred from the passed style type,
|
|
6266
|
+
* the command tries to convert selected items to a list of that type.
|
|
6267
|
+
* It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
|
|
6268
|
+
*/ class LegacyListStyleCommand extends Command {
|
|
6269
|
+
/**
|
|
6270
|
+
* The default type of the list style.
|
|
6271
|
+
*/ defaultType;
|
|
6272
|
+
/**
|
|
6273
|
+
* Creates an instance of the command.
|
|
6274
|
+
*
|
|
6275
|
+
* @param editor The editor instance.
|
|
6276
|
+
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
6277
|
+
* the command execution.
|
|
6278
|
+
*/ constructor(editor, defaultType){
|
|
6279
|
+
super(editor);
|
|
6280
|
+
this.defaultType = defaultType;
|
|
6281
|
+
}
|
|
6099
6282
|
/**
|
|
6100
|
-
|
|
6101
|
-
|
|
6283
|
+
* @inheritDoc
|
|
6284
|
+
*/ refresh() {
|
|
6102
6285
|
this.value = this._getValue();
|
|
6103
6286
|
this.isEnabled = this._checkEnabled();
|
|
6104
6287
|
}
|
|
6105
6288
|
/**
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6289
|
+
* Executes the command.
|
|
6290
|
+
*
|
|
6291
|
+
* @fires execute
|
|
6292
|
+
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
6293
|
+
* style will be applied.
|
|
6294
|
+
*/ execute(options = {}) {
|
|
6112
6295
|
this._tryToConvertItemsToList(options);
|
|
6113
6296
|
const model = this.editor.model;
|
|
6114
6297
|
const listItems = getSelectedListItems(model);
|
|
@@ -6122,10 +6305,10 @@ class LegacyListStyleCommand extends Command {
|
|
|
6122
6305
|
});
|
|
6123
6306
|
}
|
|
6124
6307
|
/**
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6308
|
+
* Checks the command's {@link #value}.
|
|
6309
|
+
*
|
|
6310
|
+
* @returns The current value.
|
|
6311
|
+
*/ _getValue() {
|
|
6129
6312
|
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
6130
6313
|
if (listItem && listItem.is('element', 'listItem')) {
|
|
6131
6314
|
return listItem.getAttribute('listStyle');
|
|
@@ -6133,20 +6316,20 @@ class LegacyListStyleCommand extends Command {
|
|
|
6133
6316
|
return null;
|
|
6134
6317
|
}
|
|
6135
6318
|
/**
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6319
|
+
* Checks whether the command can be enabled in the current context.
|
|
6320
|
+
*
|
|
6321
|
+
* @returns Whether the command should be enabled.
|
|
6322
|
+
*/ _checkEnabled() {
|
|
6140
6323
|
const editor = this.editor;
|
|
6141
6324
|
const numberedList = editor.commands.get('numberedList');
|
|
6142
6325
|
const bulletedList = editor.commands.get('bulletedList');
|
|
6143
6326
|
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
6144
6327
|
}
|
|
6145
6328
|
/**
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6329
|
+
* Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
|
|
6330
|
+
*
|
|
6331
|
+
* @param The type of the list style. If `null` is specified, the function does nothing.
|
|
6332
|
+
*/ _tryToConvertItemsToList(options) {
|
|
6150
6333
|
if (!options.type) {
|
|
6151
6334
|
return;
|
|
6152
6335
|
}
|
|
@@ -6161,32 +6344,26 @@ class LegacyListStyleCommand extends Command {
|
|
|
6161
6344
|
editor.execute(commandName);
|
|
6162
6345
|
}
|
|
6163
6346
|
}
|
|
6164
|
-
/**
|
|
6165
|
-
* Creates an instance of the command.
|
|
6166
|
-
*
|
|
6167
|
-
* @param editor The editor instance.
|
|
6168
|
-
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
6169
|
-
* the command execution.
|
|
6170
|
-
*/ constructor(editor, defaultType){
|
|
6171
|
-
super(editor);
|
|
6172
|
-
this.defaultType = defaultType;
|
|
6173
|
-
}
|
|
6174
6347
|
}
|
|
6175
6348
|
|
|
6176
|
-
|
|
6349
|
+
/**
|
|
6350
|
+
* The reversed list command. It changes the `listReversed` attribute of the selected list items. As a result, the list order will be
|
|
6351
|
+
* reversed.
|
|
6352
|
+
* It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
|
|
6353
|
+
*/ class LegacyListReversedCommand extends Command {
|
|
6177
6354
|
/**
|
|
6178
|
-
|
|
6179
|
-
|
|
6355
|
+
* @inheritDoc
|
|
6356
|
+
*/ refresh() {
|
|
6180
6357
|
const value = this._getValue();
|
|
6181
6358
|
this.value = value;
|
|
6182
6359
|
this.isEnabled = value != null;
|
|
6183
6360
|
}
|
|
6184
6361
|
/**
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6362
|
+
* Executes the command.
|
|
6363
|
+
*
|
|
6364
|
+
* @fires execute
|
|
6365
|
+
* @param options.reversed Whether the list should be reversed.
|
|
6366
|
+
*/ execute(options = {}) {
|
|
6190
6367
|
const model = this.editor.model;
|
|
6191
6368
|
const listItems = getSelectedListItems(model).filter((item)=>item.getAttribute('listType') == 'numbered');
|
|
6192
6369
|
model.change((writer)=>{
|
|
@@ -6196,10 +6373,10 @@ class LegacyListReversedCommand extends Command {
|
|
|
6196
6373
|
});
|
|
6197
6374
|
}
|
|
6198
6375
|
/**
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6376
|
+
* Checks the command's {@link #value}.
|
|
6377
|
+
*
|
|
6378
|
+
* @returns The current value.
|
|
6379
|
+
*/ _getValue() {
|
|
6203
6380
|
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
6204
6381
|
if (listItem && listItem.is('element', 'listItem') && listItem.getAttribute('listType') == 'numbered') {
|
|
6205
6382
|
return listItem.getAttribute('listReversed');
|
|
@@ -6208,20 +6385,23 @@ class LegacyListReversedCommand extends Command {
|
|
|
6208
6385
|
}
|
|
6209
6386
|
}
|
|
6210
6387
|
|
|
6211
|
-
|
|
6388
|
+
/**
|
|
6389
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items.
|
|
6390
|
+
* It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
|
|
6391
|
+
*/ class LegacyListStartCommand extends Command {
|
|
6212
6392
|
/**
|
|
6213
|
-
|
|
6214
|
-
|
|
6393
|
+
* @inheritDoc
|
|
6394
|
+
*/ refresh() {
|
|
6215
6395
|
const value = this._getValue();
|
|
6216
6396
|
this.value = value;
|
|
6217
6397
|
this.isEnabled = value != null;
|
|
6218
6398
|
}
|
|
6219
6399
|
/**
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6400
|
+
* Executes the command.
|
|
6401
|
+
*
|
|
6402
|
+
* @fires execute
|
|
6403
|
+
* @param options.startIndex The list start index.
|
|
6404
|
+
*/ execute({ startIndex = 1 } = {}) {
|
|
6225
6405
|
const model = this.editor.model;
|
|
6226
6406
|
const listItems = getSelectedListItems(model).filter((item)=>item.getAttribute('listType') == 'numbered');
|
|
6227
6407
|
model.change((writer)=>{
|
|
@@ -6231,10 +6411,10 @@ class LegacyListStartCommand extends Command {
|
|
|
6231
6411
|
});
|
|
6232
6412
|
}
|
|
6233
6413
|
/**
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6414
|
+
* Checks the command's {@link #value}.
|
|
6415
|
+
*
|
|
6416
|
+
* @returns The current value.
|
|
6417
|
+
*/ _getValue() {
|
|
6238
6418
|
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
6239
6419
|
if (listItem && listItem.is('element', 'listItem') && listItem.getAttribute('listType') == 'numbered') {
|
|
6240
6420
|
return listItem.getAttribute('listStart');
|
|
@@ -6244,22 +6424,42 @@ class LegacyListStartCommand extends Command {
|
|
|
6244
6424
|
}
|
|
6245
6425
|
|
|
6246
6426
|
const DEFAULT_LIST_TYPE = 'default';
|
|
6247
|
-
|
|
6427
|
+
/**
|
|
6428
|
+
* The engine of the list properties feature.
|
|
6429
|
+
*
|
|
6430
|
+
* It sets the value for the `listItem` attribute of the {@link module:list/legacylist~LegacyList `<listItem>`} element that
|
|
6431
|
+
* allows modifying the list style type.
|
|
6432
|
+
*
|
|
6433
|
+
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
6434
|
+
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
6435
|
+
*/ class LegacyListPropertiesEditing extends Plugin {
|
|
6248
6436
|
/**
|
|
6249
|
-
|
|
6250
|
-
|
|
6437
|
+
* @inheritDoc
|
|
6438
|
+
*/ static get requires() {
|
|
6251
6439
|
return [
|
|
6252
6440
|
LegacyListEditing
|
|
6253
6441
|
];
|
|
6254
6442
|
}
|
|
6255
6443
|
/**
|
|
6256
|
-
|
|
6257
|
-
|
|
6444
|
+
* @inheritDoc
|
|
6445
|
+
*/ static get pluginName() {
|
|
6258
6446
|
return 'LegacyListPropertiesEditing';
|
|
6259
6447
|
}
|
|
6260
6448
|
/**
|
|
6261
|
-
|
|
6262
|
-
|
|
6449
|
+
* @inheritDoc
|
|
6450
|
+
*/ constructor(editor){
|
|
6451
|
+
super(editor);
|
|
6452
|
+
editor.config.define('list', {
|
|
6453
|
+
properties: {
|
|
6454
|
+
styles: true,
|
|
6455
|
+
startIndex: false,
|
|
6456
|
+
reversed: false
|
|
6457
|
+
}
|
|
6458
|
+
});
|
|
6459
|
+
}
|
|
6460
|
+
/**
|
|
6461
|
+
* @inheritDoc
|
|
6462
|
+
*/ init() {
|
|
6263
6463
|
const editor = this.editor;
|
|
6264
6464
|
const model = editor.model;
|
|
6265
6465
|
const enabledProperties = editor.config.get('list.properties');
|
|
@@ -6285,8 +6485,8 @@ class LegacyListPropertiesEditing extends Plugin {
|
|
|
6285
6485
|
this._mergeListAttributesWhileMergingLists(strategies);
|
|
6286
6486
|
}
|
|
6287
6487
|
/**
|
|
6288
|
-
|
|
6289
|
-
|
|
6488
|
+
* @inheritDoc
|
|
6489
|
+
*/ afterInit() {
|
|
6290
6490
|
const editor = this.editor;
|
|
6291
6491
|
// Enable post-fixer that removes the attributes from to-do list items only if the "TodoList" plugin is on.
|
|
6292
6492
|
// We need to registry the hook here since the `TodoList` plugin can be added after the `ListPropertiesEditing`.
|
|
@@ -6295,36 +6495,36 @@ class LegacyListPropertiesEditing extends Plugin {
|
|
|
6295
6495
|
}
|
|
6296
6496
|
}
|
|
6297
6497
|
/**
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6498
|
+
* Starts listening to {@link module:engine/model/model~Model#deleteContent} and checks whether two lists will be merged into a single
|
|
6499
|
+
* one after deleting the content.
|
|
6500
|
+
*
|
|
6501
|
+
* The purpose of this action is to adjust the `listStyle`, `listReversed` and `listStart` values
|
|
6502
|
+
* for the list that was merged.
|
|
6503
|
+
*
|
|
6504
|
+
* Consider the following model's content:
|
|
6505
|
+
*
|
|
6506
|
+
* ```xml
|
|
6507
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 1</listItem>
|
|
6508
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 2</listItem>
|
|
6509
|
+
* <paragraph>[A paragraph.]</paragraph>
|
|
6510
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="circle">UL List item 1</listItem>
|
|
6511
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="circle">UL List item 2</listItem>
|
|
6512
|
+
* ```
|
|
6513
|
+
*
|
|
6514
|
+
* After removing the paragraph element, the second list will be merged into the first one.
|
|
6515
|
+
* We want to inherit the `listStyle` attribute for the second list from the first one.
|
|
6516
|
+
*
|
|
6517
|
+
* ```xml
|
|
6518
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 1</listItem>
|
|
6519
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 2</listItem>
|
|
6520
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 1</listItem>
|
|
6521
|
+
* <listItem listIndent="0" listType="bulleted" listStyle="square">UL List item 2</listItem>
|
|
6522
|
+
* ```
|
|
6523
|
+
*
|
|
6524
|
+
* See https://github.com/ckeditor/ckeditor5/issues/7879.
|
|
6525
|
+
*
|
|
6526
|
+
* @param attributeStrategies Strategies for the enabled attributes.
|
|
6527
|
+
*/ _mergeListAttributesWhileMergingLists(attributeStrategies) {
|
|
6328
6528
|
const editor = this.editor;
|
|
6329
6529
|
const model = editor.model;
|
|
6330
6530
|
// First the outer-most`listItem` in the first list reference.
|
|
@@ -6418,18 +6618,6 @@ class LegacyListPropertiesEditing extends Plugin {
|
|
|
6418
6618
|
priority: 'low'
|
|
6419
6619
|
});
|
|
6420
6620
|
}
|
|
6421
|
-
/**
|
|
6422
|
-
* @inheritDoc
|
|
6423
|
-
*/ constructor(editor){
|
|
6424
|
-
super(editor);
|
|
6425
|
-
editor.config.define('list', {
|
|
6426
|
-
properties: {
|
|
6427
|
-
styles: true,
|
|
6428
|
-
startIndex: false,
|
|
6429
|
-
reversed: false
|
|
6430
|
-
}
|
|
6431
|
-
});
|
|
6432
|
-
}
|
|
6433
6621
|
}
|
|
6434
6622
|
/**
|
|
6435
6623
|
* Creates an array of strategies for dealing with enabled listItem attributes.
|
|
@@ -6554,8 +6742,8 @@ class LegacyListPropertiesEditing extends Plugin {
|
|
|
6554
6742
|
}
|
|
6555
6743
|
};
|
|
6556
6744
|
/**
|
|
6557
|
-
|
|
6558
|
-
|
|
6745
|
+
* Checks whether specified list items belong to the same list.
|
|
6746
|
+
*/ function areRepresentingSameList(listItem1, listItem2) {
|
|
6559
6747
|
return listItem2 && listItem1.getAttribute('listType') === listItem2.getAttribute('listType') && listItem1.getAttribute('listIndent') === listItem2.getAttribute('listIndent') && listItem1.getAttribute('listStyle') === listItem2.getAttribute('listStyle') && listItem1.getAttribute('listReversed') === listItem2.getAttribute('listReversed') && listItem1.getAttribute('listStart') === listItem2.getAttribute('listStart');
|
|
6560
6748
|
}
|
|
6561
6749
|
}
|
|
@@ -6895,34 +7083,63 @@ function getItemFromChange(change) {
|
|
|
6895
7083
|
return null;
|
|
6896
7084
|
}
|
|
6897
7085
|
|
|
6898
|
-
|
|
7086
|
+
/**
|
|
7087
|
+
* The legacy list properties feature.
|
|
7088
|
+
*
|
|
7089
|
+
* This is a "glue" plugin that loads the {@link module:list/legacylistproperties/legacylistpropertiesediting~LegacyListPropertiesEditing
|
|
7090
|
+
* legacy list properties editing feature} and the
|
|
7091
|
+
* {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
7092
|
+
*/ class LegacyListProperties extends Plugin {
|
|
6899
7093
|
/**
|
|
6900
|
-
|
|
6901
|
-
|
|
7094
|
+
* @inheritDoc
|
|
7095
|
+
*/ static get requires() {
|
|
6902
7096
|
return [
|
|
6903
7097
|
LegacyListPropertiesEditing,
|
|
6904
7098
|
ListPropertiesUI
|
|
6905
7099
|
];
|
|
6906
7100
|
}
|
|
6907
7101
|
/**
|
|
6908
|
-
|
|
6909
|
-
|
|
7102
|
+
* @inheritDoc
|
|
7103
|
+
*/ static get pluginName() {
|
|
6910
7104
|
return 'LegacyListProperties';
|
|
6911
7105
|
}
|
|
6912
7106
|
}
|
|
6913
7107
|
|
|
6914
7108
|
const attributeKey = 'todoListChecked';
|
|
6915
|
-
|
|
7109
|
+
/**
|
|
7110
|
+
* The check to-do command.
|
|
7111
|
+
*
|
|
7112
|
+
* The command is registered by the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing} as
|
|
7113
|
+
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
7114
|
+
*/ class LegacyCheckTodoListCommand extends Command {
|
|
7115
|
+
/**
|
|
7116
|
+
* A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
7117
|
+
*
|
|
7118
|
+
* @internal
|
|
7119
|
+
*/ _selectedElements;
|
|
6916
7120
|
/**
|
|
6917
|
-
|
|
6918
|
-
|
|
7121
|
+
* @inheritDoc
|
|
7122
|
+
*/ constructor(editor){
|
|
7123
|
+
super(editor);
|
|
7124
|
+
this._selectedElements = [];
|
|
7125
|
+
// Refresh command before executing to be sure all values are up to date.
|
|
7126
|
+
// It is needed when selection has changed before command execution, in the same change block.
|
|
7127
|
+
this.on('execute', ()=>{
|
|
7128
|
+
this.refresh();
|
|
7129
|
+
}, {
|
|
7130
|
+
priority: 'highest'
|
|
7131
|
+
});
|
|
7132
|
+
}
|
|
7133
|
+
/**
|
|
7134
|
+
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
7135
|
+
*/ refresh() {
|
|
6919
7136
|
this._selectedElements = this._getSelectedItems();
|
|
6920
7137
|
this.value = this._selectedElements.every((element)=>!!element.getAttribute(attributeKey));
|
|
6921
7138
|
this.isEnabled = !!this._selectedElements.length;
|
|
6922
7139
|
}
|
|
6923
7140
|
/**
|
|
6924
|
-
|
|
6925
|
-
|
|
7141
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
7142
|
+
*/ _getSelectedItems() {
|
|
6926
7143
|
const model = this.editor.model;
|
|
6927
7144
|
const schema = model.schema;
|
|
6928
7145
|
const selectionRange = model.document.selection.getFirstRange();
|
|
@@ -6939,12 +7156,12 @@ class LegacyCheckTodoListCommand extends Command {
|
|
|
6939
7156
|
return elements;
|
|
6940
7157
|
}
|
|
6941
7158
|
/**
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
7159
|
+
* Executes the command.
|
|
7160
|
+
*
|
|
7161
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
7162
|
+
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
7163
|
+
* value to decide what it should do.
|
|
7164
|
+
*/ execute(options = {}) {
|
|
6948
7165
|
this.editor.model.change((writer)=>{
|
|
6949
7166
|
for (const element of this._selectedElements){
|
|
6950
7167
|
const value = options.forceValue === undefined ? !this.value : options.forceValue;
|
|
@@ -6956,19 +7173,6 @@ class LegacyCheckTodoListCommand extends Command {
|
|
|
6956
7173
|
}
|
|
6957
7174
|
});
|
|
6958
7175
|
}
|
|
6959
|
-
/**
|
|
6960
|
-
* @inheritDoc
|
|
6961
|
-
*/ constructor(editor){
|
|
6962
|
-
super(editor);
|
|
6963
|
-
this._selectedElements = [];
|
|
6964
|
-
// Refresh command before executing to be sure all values are up to date.
|
|
6965
|
-
// It is needed when selection has changed before command execution, in the same change block.
|
|
6966
|
-
this.on('execute', ()=>{
|
|
6967
|
-
this.refresh();
|
|
6968
|
-
}, {
|
|
6969
|
-
priority: 'highest'
|
|
6970
|
-
});
|
|
6971
|
-
}
|
|
6972
7176
|
}
|
|
6973
7177
|
|
|
6974
7178
|
/**
|
|
@@ -7220,23 +7424,32 @@ function findDescription(viewItem, view) {
|
|
|
7220
7424
|
}
|
|
7221
7425
|
}
|
|
7222
7426
|
|
|
7223
|
-
const ITEM_TOGGLE_KEYSTROKE = parseKeystroke('Ctrl+Enter');
|
|
7224
|
-
|
|
7427
|
+
const ITEM_TOGGLE_KEYSTROKE = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
7428
|
+
/**
|
|
7429
|
+
* The engine of the to-do list feature. It handles creating, editing and removing to-do lists and their items.
|
|
7430
|
+
*
|
|
7431
|
+
* It registers the entire functionality of the {@link module:list/legacylist/legacylistediting~LegacyListEditing legacy list editing
|
|
7432
|
+
* plugin} and extends it with the commands:
|
|
7433
|
+
*
|
|
7434
|
+
* - `'todoList'`,
|
|
7435
|
+
* - `'checkTodoList'`,
|
|
7436
|
+
* - `'todoListCheck'` as an alias for `checkTodoList` command.
|
|
7437
|
+
*/ class LegacyTodoListEditing extends Plugin {
|
|
7225
7438
|
/**
|
|
7226
|
-
|
|
7227
|
-
|
|
7439
|
+
* @inheritDoc
|
|
7440
|
+
*/ static get pluginName() {
|
|
7228
7441
|
return 'LegacyTodoListEditing';
|
|
7229
7442
|
}
|
|
7230
7443
|
/**
|
|
7231
|
-
|
|
7232
|
-
|
|
7444
|
+
* @inheritDoc
|
|
7445
|
+
*/ static get requires() {
|
|
7233
7446
|
return [
|
|
7234
7447
|
LegacyListEditing
|
|
7235
7448
|
];
|
|
7236
7449
|
}
|
|
7237
7450
|
/**
|
|
7238
|
-
|
|
7239
|
-
|
|
7451
|
+
* @inheritDoc
|
|
7452
|
+
*/ init() {
|
|
7240
7453
|
const editor = this.editor;
|
|
7241
7454
|
const { editing, data, model } = editor;
|
|
7242
7455
|
// Extend schema.
|
|
@@ -7323,13 +7536,13 @@ class LegacyTodoListEditing extends Plugin {
|
|
|
7323
7536
|
this._initAriaAnnouncements();
|
|
7324
7537
|
}
|
|
7325
7538
|
/**
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7539
|
+
* Handles the checkbox element change, moves the selection to the corresponding model item to make it possible
|
|
7540
|
+
* to toggle the `todoListChecked` attribute using the command, and restores the selection position.
|
|
7541
|
+
*
|
|
7542
|
+
* Some say it's a hack :) Moving the selection only for executing the command on a certain node and restoring it after,
|
|
7543
|
+
* is not a clear solution. We need to design an API for using commands beyond the selection range.
|
|
7544
|
+
* See https://github.com/ckeditor/ckeditor5/issues/1954.
|
|
7545
|
+
*/ _handleCheckmarkChange(listItem) {
|
|
7333
7546
|
const editor = this.editor;
|
|
7334
7547
|
const model = editor.model;
|
|
7335
7548
|
const previousSelectionRanges = Array.from(model.document.selection.getRanges());
|
|
@@ -7340,11 +7553,11 @@ class LegacyTodoListEditing extends Plugin {
|
|
|
7340
7553
|
});
|
|
7341
7554
|
}
|
|
7342
7555
|
/**
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7556
|
+
* Observe when user enters or leaves todo list and set proper aria value in global live announcer.
|
|
7557
|
+
* This allows screen readers to indicate when the user has entered and left the specified todo list.
|
|
7558
|
+
*
|
|
7559
|
+
* @internal
|
|
7560
|
+
*/ _initAriaAnnouncements() {
|
|
7348
7561
|
const { model, ui, t } = this.editor;
|
|
7349
7562
|
let lastFocusedCodeBlock = null;
|
|
7350
7563
|
if (!ui) {
|
|
@@ -7399,31 +7612,36 @@ class LegacyTodoListEditing extends Plugin {
|
|
|
7399
7612
|
return !!element && element.is('element', 'listItem') && element.getAttribute('listType') === 'todo';
|
|
7400
7613
|
}
|
|
7401
7614
|
|
|
7402
|
-
|
|
7615
|
+
/**
|
|
7616
|
+
* The legacy to-do list feature.
|
|
7617
|
+
*
|
|
7618
|
+
* This is a "glue" plugin that loads the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing legacy to-do list
|
|
7619
|
+
* editing feature} and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
7620
|
+
*/ class LegacyTodoList extends Plugin {
|
|
7403
7621
|
/**
|
|
7404
|
-
|
|
7405
|
-
|
|
7622
|
+
* @inheritDoc
|
|
7623
|
+
*/ static get requires() {
|
|
7406
7624
|
return [
|
|
7407
7625
|
LegacyTodoListEditing,
|
|
7408
7626
|
TodoListUI
|
|
7409
7627
|
];
|
|
7410
7628
|
}
|
|
7411
7629
|
/**
|
|
7412
|
-
|
|
7413
|
-
|
|
7630
|
+
* @inheritDoc
|
|
7631
|
+
*/ static get pluginName() {
|
|
7414
7632
|
return 'LegacyTodoList';
|
|
7415
7633
|
}
|
|
7416
7634
|
}
|
|
7417
7635
|
|
|
7418
7636
|
class AdjacentListsSupport extends Plugin {
|
|
7419
7637
|
/**
|
|
7420
|
-
|
|
7421
|
-
|
|
7638
|
+
* @inheritDoc
|
|
7639
|
+
*/ static get pluginName() {
|
|
7422
7640
|
return 'AdjacentListsSupport';
|
|
7423
7641
|
}
|
|
7424
7642
|
/**
|
|
7425
|
-
|
|
7426
|
-
|
|
7643
|
+
* @inheritDoc
|
|
7644
|
+
*/ init() {
|
|
7427
7645
|
const editor = this.editor;
|
|
7428
7646
|
const model = editor.model;
|
|
7429
7647
|
model.schema.register('listSeparator', {
|
|
@@ -7490,76 +7708,97 @@ class AdjacentListsSupport extends Plugin {
|
|
|
7490
7708
|
};
|
|
7491
7709
|
}
|
|
7492
7710
|
|
|
7493
|
-
|
|
7711
|
+
/**
|
|
7712
|
+
* The document list feature.
|
|
7713
|
+
*
|
|
7714
|
+
* This is an obsolete plugin that exists for backward compatibility only.
|
|
7715
|
+
* Use the {@link module:list/list~List `List`} instead.
|
|
7716
|
+
*
|
|
7717
|
+
* @deprecated
|
|
7718
|
+
*/ class DocumentList extends Plugin {
|
|
7494
7719
|
/**
|
|
7495
|
-
|
|
7496
|
-
|
|
7720
|
+
* @inheritDoc
|
|
7721
|
+
*/ static get requires() {
|
|
7497
7722
|
return [
|
|
7498
7723
|
List
|
|
7499
7724
|
];
|
|
7500
7725
|
}
|
|
7501
7726
|
/**
|
|
7502
|
-
|
|
7503
|
-
|
|
7727
|
+
* @inheritDoc
|
|
7728
|
+
*/ static get pluginName() {
|
|
7504
7729
|
return 'DocumentList';
|
|
7505
7730
|
}
|
|
7506
7731
|
constructor(editor){
|
|
7507
7732
|
super(editor);
|
|
7508
7733
|
/**
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7734
|
+
* The `DocumentList` plugin is obsolete. Use `List` instead.
|
|
7735
|
+
*
|
|
7736
|
+
* @error plugin-obsolete-documentlist
|
|
7737
|
+
*/ logWarning('plugin-obsolete-documentlist', {
|
|
7513
7738
|
pluginName: 'DocumentList'
|
|
7514
7739
|
});
|
|
7515
7740
|
}
|
|
7516
7741
|
}
|
|
7517
7742
|
|
|
7518
|
-
|
|
7743
|
+
/**
|
|
7744
|
+
* The document list properties feature.
|
|
7745
|
+
*
|
|
7746
|
+
* This is an obsolete plugin that exists for backward compatibility only.
|
|
7747
|
+
* Use the {@link module:list/listproperties~ListProperties `ListProperties`} instead.
|
|
7748
|
+
*
|
|
7749
|
+
* @deprecated
|
|
7750
|
+
*/ class DocumentListProperties extends Plugin {
|
|
7519
7751
|
/**
|
|
7520
|
-
|
|
7521
|
-
|
|
7752
|
+
* @inheritDoc
|
|
7753
|
+
*/ static get requires() {
|
|
7522
7754
|
return [
|
|
7523
7755
|
ListProperties
|
|
7524
7756
|
];
|
|
7525
7757
|
}
|
|
7526
7758
|
/**
|
|
7527
|
-
|
|
7528
|
-
|
|
7759
|
+
* @inheritDoc
|
|
7760
|
+
*/ static get pluginName() {
|
|
7529
7761
|
return 'DocumentListProperties';
|
|
7530
7762
|
}
|
|
7531
7763
|
constructor(editor){
|
|
7532
7764
|
super(editor);
|
|
7533
7765
|
/**
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7766
|
+
* The `DocumentListProperties` plugin is obsolete. Use `ListProperties` instead.
|
|
7767
|
+
*
|
|
7768
|
+
* @error plugin-obsolete-documentlistproperties
|
|
7769
|
+
*/ logWarning('plugin-obsolete-documentlistproperties', {
|
|
7538
7770
|
pluginName: 'DocumentListProperties'
|
|
7539
7771
|
});
|
|
7540
7772
|
}
|
|
7541
7773
|
}
|
|
7542
7774
|
|
|
7543
|
-
|
|
7775
|
+
/**
|
|
7776
|
+
* The to-do list feature.
|
|
7777
|
+
*
|
|
7778
|
+
* This is an obsolete plugin that exists for backward compatibility only.
|
|
7779
|
+
* Use the {@link module:list/todolist~TodoList `TodoList`} instead.
|
|
7780
|
+
*
|
|
7781
|
+
* @deprecated
|
|
7782
|
+
*/ class TodoDocumentList extends Plugin {
|
|
7544
7783
|
/**
|
|
7545
|
-
|
|
7546
|
-
|
|
7784
|
+
* @inheritDoc
|
|
7785
|
+
*/ static get requires() {
|
|
7547
7786
|
return [
|
|
7548
7787
|
TodoList
|
|
7549
7788
|
];
|
|
7550
7789
|
}
|
|
7551
7790
|
/**
|
|
7552
|
-
|
|
7553
|
-
|
|
7791
|
+
* @inheritDoc
|
|
7792
|
+
*/ static get pluginName() {
|
|
7554
7793
|
return 'TodoDocumentList';
|
|
7555
7794
|
}
|
|
7556
7795
|
constructor(editor){
|
|
7557
7796
|
super(editor);
|
|
7558
7797
|
/**
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7798
|
+
* The `TodoDocumentList` plugin is obsolete. Use `TodoList` instead.
|
|
7799
|
+
*
|
|
7800
|
+
* @error plugin-obsolete-tododocumentlist
|
|
7801
|
+
*/ logWarning('plugin-obsolete-tododocumentlist', {
|
|
7563
7802
|
pluginName: 'TodoDocumentList'
|
|
7564
7803
|
});
|
|
7565
7804
|
}
|