@ckeditor/ckeditor5-widget 35.2.0 → 35.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +31 -23
- package/src/highlightstack.js +105 -139
- package/src/index.js +0 -1
- package/src/utils.js +127 -181
- package/src/verticalnavigation.js +144 -187
- package/src/widget.js +359 -435
- package/src/widgetresize/resizer.js +412 -505
- package/src/widgetresize/resizerstate.js +154 -176
- package/src/widgetresize/sizeview.js +79 -98
- package/src/widgetresize.js +199 -297
- package/src/widgettoolbarrepository.js +244 -296
- package/src/widgettypearound/utils.js +11 -20
- package/src/widgettypearound/widgettypearound.js +748 -876
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-widget",
|
3
|
-
"version": "35.
|
3
|
+
"version": "35.3.0",
|
4
4
|
"description": "Widget API for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -11,29 +11,32 @@
|
|
11
11
|
],
|
12
12
|
"main": "src/index.js",
|
13
13
|
"dependencies": {
|
14
|
-
"@ckeditor/ckeditor5-core": "^35.
|
15
|
-
"@ckeditor/ckeditor5-engine": "^35.
|
16
|
-
"@ckeditor/ckeditor5-enter": "^35.
|
17
|
-
"@ckeditor/ckeditor5-ui": "^35.
|
18
|
-
"@ckeditor/ckeditor5-utils": "^35.
|
19
|
-
"@ckeditor/ckeditor5-typing": "^35.
|
14
|
+
"@ckeditor/ckeditor5-core": "^35.3.0",
|
15
|
+
"@ckeditor/ckeditor5-engine": "^35.3.0",
|
16
|
+
"@ckeditor/ckeditor5-enter": "^35.3.0",
|
17
|
+
"@ckeditor/ckeditor5-ui": "^35.3.0",
|
18
|
+
"@ckeditor/ckeditor5-utils": "^35.3.0",
|
19
|
+
"@ckeditor/ckeditor5-typing": "^35.3.0",
|
20
20
|
"lodash-es": "^4.17.15"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
|
-
"@ckeditor/ckeditor5-basic-styles": "^35.
|
24
|
-
"@ckeditor/ckeditor5-block-quote": "^35.
|
25
|
-
"@ckeditor/ckeditor5-clipboard": "^35.
|
26
|
-
"@ckeditor/ckeditor5-editor-balloon": "^35.
|
27
|
-
"@ckeditor/ckeditor5-editor-classic": "^35.
|
28
|
-
"@ckeditor/ckeditor5-essentials": "^35.
|
29
|
-
"@ckeditor/ckeditor5-heading": "^35.
|
30
|
-
"@ckeditor/ckeditor5-horizontal-line": "^35.
|
31
|
-
"@ckeditor/ckeditor5-image": "^35.
|
32
|
-
"@ckeditor/ckeditor5-link": "^35.
|
33
|
-
"@ckeditor/ckeditor5-media-embed": "^35.
|
34
|
-
"@ckeditor/ckeditor5-paragraph": "^35.
|
35
|
-
"@ckeditor/ckeditor5-table": "^35.
|
36
|
-
"@ckeditor/ckeditor5-undo": "^35.
|
23
|
+
"@ckeditor/ckeditor5-basic-styles": "^35.3.0",
|
24
|
+
"@ckeditor/ckeditor5-block-quote": "^35.3.0",
|
25
|
+
"@ckeditor/ckeditor5-clipboard": "^35.3.0",
|
26
|
+
"@ckeditor/ckeditor5-editor-balloon": "^35.3.0",
|
27
|
+
"@ckeditor/ckeditor5-editor-classic": "^35.3.0",
|
28
|
+
"@ckeditor/ckeditor5-essentials": "^35.3.0",
|
29
|
+
"@ckeditor/ckeditor5-heading": "^35.3.0",
|
30
|
+
"@ckeditor/ckeditor5-horizontal-line": "^35.3.0",
|
31
|
+
"@ckeditor/ckeditor5-image": "^35.3.0",
|
32
|
+
"@ckeditor/ckeditor5-link": "^35.3.0",
|
33
|
+
"@ckeditor/ckeditor5-media-embed": "^35.3.0",
|
34
|
+
"@ckeditor/ckeditor5-paragraph": "^35.3.0",
|
35
|
+
"@ckeditor/ckeditor5-table": "^35.3.0",
|
36
|
+
"@ckeditor/ckeditor5-undo": "^35.3.0",
|
37
|
+
"typescript": "^4.8.4",
|
38
|
+
"webpack": "^5.58.1",
|
39
|
+
"webpack-cli": "^4.9.0"
|
37
40
|
},
|
38
41
|
"engines": {
|
39
42
|
"node": ">=14.0.0",
|
@@ -50,9 +53,14 @@
|
|
50
53
|
},
|
51
54
|
"files": [
|
52
55
|
"lang",
|
53
|
-
"src",
|
56
|
+
"src/**/*.js",
|
57
|
+
"src/**/*.d.ts",
|
54
58
|
"theme",
|
55
59
|
"ckeditor5-metadata.json",
|
56
60
|
"CHANGELOG.md"
|
57
|
-
]
|
61
|
+
],
|
62
|
+
"scripts": {
|
63
|
+
"build": "tsc -p ./tsconfig.release.json",
|
64
|
+
"postversion": "npm run build"
|
65
|
+
}
|
58
66
|
}
|
package/src/highlightstack.js
CHANGED
@@ -2,14 +2,10 @@
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
4
|
*/
|
5
|
-
|
6
5
|
/**
|
7
6
|
* @module widget/highlightstack
|
8
7
|
*/
|
9
|
-
|
10
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
11
|
-
import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
12
|
-
|
8
|
+
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
13
9
|
/**
|
14
10
|
* Class used to handle correct order of highlights on elements.
|
15
11
|
*
|
@@ -21,156 +17,126 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
21
17
|
*
|
22
18
|
* This way, highlight will be applied with the same rules it is applied on texts.
|
23
19
|
*/
|
24
|
-
export default class HighlightStack {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
*
|
116
|
-
* @private
|
117
|
-
* @param {String} id Descriptor's id.
|
118
|
-
*/
|
119
|
-
_removeDescriptor( id ) {
|
120
|
-
const stack = this._stack;
|
121
|
-
const index = stack.findIndex( item => item.id === id );
|
122
|
-
|
123
|
-
// If descriptor with same id is on the list - remove it.
|
124
|
-
if ( index > -1 ) {
|
125
|
-
stack.splice( index, 1 );
|
126
|
-
}
|
127
|
-
}
|
20
|
+
export default class HighlightStack extends Emitter {
|
21
|
+
/**
|
22
|
+
* Creates class instance.
|
23
|
+
*/
|
24
|
+
constructor() {
|
25
|
+
super();
|
26
|
+
this._stack = [];
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Adds highlight descriptor to the stack.
|
30
|
+
*
|
31
|
+
* @fires change:top
|
32
|
+
* @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} descriptor
|
33
|
+
* @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
34
|
+
*/
|
35
|
+
add(descriptor, writer) {
|
36
|
+
const stack = this._stack;
|
37
|
+
// Save top descriptor and insert new one. If top is changed - fire event.
|
38
|
+
const oldTop = stack[0];
|
39
|
+
this._insertDescriptor(descriptor);
|
40
|
+
const newTop = stack[0];
|
41
|
+
// When new object is at the top and stores different information.
|
42
|
+
if (oldTop !== newTop && !compareDescriptors(oldTop, newTop)) {
|
43
|
+
this.fire('change:top', {
|
44
|
+
oldDescriptor: oldTop,
|
45
|
+
newDescriptor: newTop,
|
46
|
+
writer
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Removes highlight descriptor from the stack.
|
52
|
+
*
|
53
|
+
* @fires change:top
|
54
|
+
* @param {String} id Id of the descriptor to remove.
|
55
|
+
* @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
56
|
+
*/
|
57
|
+
remove(id, writer) {
|
58
|
+
const stack = this._stack;
|
59
|
+
const oldTop = stack[0];
|
60
|
+
this._removeDescriptor(id);
|
61
|
+
const newTop = stack[0];
|
62
|
+
// When new object is at the top and stores different information.
|
63
|
+
if (oldTop !== newTop && !compareDescriptors(oldTop, newTop)) {
|
64
|
+
this.fire('change:top', {
|
65
|
+
oldDescriptor: oldTop,
|
66
|
+
newDescriptor: newTop,
|
67
|
+
writer
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Inserts given descriptor in correct place in the stack. It also takes care about updating information when
|
73
|
+
* descriptor with same id is already present.
|
74
|
+
*
|
75
|
+
* @private
|
76
|
+
* @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} descriptor
|
77
|
+
*/
|
78
|
+
_insertDescriptor(descriptor) {
|
79
|
+
const stack = this._stack;
|
80
|
+
const index = stack.findIndex(item => item.id === descriptor.id);
|
81
|
+
// Inserting exact same descriptor - do nothing.
|
82
|
+
if (compareDescriptors(descriptor, stack[index])) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
// If descriptor with same id but with different information is on the stack - remove it.
|
86
|
+
if (index > -1) {
|
87
|
+
stack.splice(index, 1);
|
88
|
+
}
|
89
|
+
// Find correct place to insert descriptor in the stack.
|
90
|
+
// It have different information (for example priority) so it must be re-inserted in correct place.
|
91
|
+
let i = 0;
|
92
|
+
while (stack[i] && shouldABeBeforeB(stack[i], descriptor)) {
|
93
|
+
i++;
|
94
|
+
}
|
95
|
+
stack.splice(i, 0, descriptor);
|
96
|
+
}
|
97
|
+
/**
|
98
|
+
* Removes descriptor with given id from the stack.
|
99
|
+
*
|
100
|
+
* @private
|
101
|
+
* @param {String} id Descriptor's id.
|
102
|
+
*/
|
103
|
+
_removeDescriptor(id) {
|
104
|
+
const stack = this._stack;
|
105
|
+
const index = stack.findIndex(item => item.id === id);
|
106
|
+
// If descriptor with same id is on the list - remove it.
|
107
|
+
if (index > -1) {
|
108
|
+
stack.splice(index, 1);
|
109
|
+
}
|
110
|
+
}
|
128
111
|
}
|
129
|
-
|
130
|
-
mix( HighlightStack, EmitterMixin );
|
131
|
-
|
132
112
|
// Compares two descriptors by checking their priority and class list.
|
133
113
|
//
|
134
114
|
// @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} a
|
135
115
|
// @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} b
|
136
116
|
// @returns {Boolean} Returns true if both descriptors are defined and have same priority and classes.
|
137
|
-
function compareDescriptors(
|
138
|
-
|
117
|
+
function compareDescriptors(a, b) {
|
118
|
+
return a && b && a.priority == b.priority && classesToString(a.classes) == classesToString(b.classes);
|
139
119
|
}
|
140
|
-
|
141
120
|
// Checks whenever first descriptor should be placed in the stack before second one.
|
142
121
|
//
|
143
122
|
// @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} a
|
144
123
|
// @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} b
|
145
124
|
// @returns {Boolean}
|
146
|
-
function shouldABeBeforeB(
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
125
|
+
function shouldABeBeforeB(a, b) {
|
126
|
+
if (a.priority > b.priority) {
|
127
|
+
return true;
|
128
|
+
}
|
129
|
+
else if (a.priority < b.priority) {
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
// When priorities are equal and names are different - use classes to compare.
|
133
|
+
return classesToString(a.classes) > classesToString(b.classes);
|
155
134
|
}
|
156
|
-
|
157
135
|
// Converts CSS classes passed with {@link module:engine/conversion/downcasthelpers~HighlightDescriptor} to
|
158
136
|
// sorted string.
|
159
137
|
//
|
160
138
|
// @param {String|Array<String>} descriptor
|
161
139
|
// @returns {String}
|
162
|
-
function classesToString(
|
163
|
-
|
140
|
+
function classesToString(classes) {
|
141
|
+
return Array.isArray(classes) ? classes.sort().join(',') : classes;
|
164
142
|
}
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Fired when top element on {@link module:widget/highlightstack~HighlightStack} has been changed
|
168
|
-
*
|
169
|
-
* @event change:top
|
170
|
-
* @param {Object} data Additional information about the change.
|
171
|
-
* @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} [data.newDescriptor] New highlight
|
172
|
-
* descriptor. It will be `undefined` when last descriptor is removed from the stack.
|
173
|
-
* @param {module:engine/conversion/downcasthelpers~HighlightDescriptor} [data.oldDescriptor] Old highlight
|
174
|
-
* descriptor. It will be `undefined` when first descriptor is added to the stack.
|
175
|
-
* @param {module:engine/view/downcastwriter~DowncastWriter} writer View writer that can be used to modify element.
|
176
|
-
*/
|
package/src/index.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
4
|
*/
|
5
|
-
|
6
5
|
export { default as Widget } from './widget';
|
7
6
|
export { default as WidgetToolbarRepository } from './widgettoolbarrepository';
|
8
7
|
export { default as WidgetResize } from './widgetresize';
|