@ckeditor/ckeditor5-minimap 35.3.2 → 36.0.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/LICENSE.md +1 -1
- package/build/minimap.js +2 -2
- package/package.json +22 -18
- package/src/index.js +1 -3
- package/src/minimap.js +140 -285
- package/src/minimapiframeview.js +70 -119
- package/src/minimappositiontrackerview.js +64 -120
- package/src/minimapview.js +120 -204
- package/src/utils.js +57 -102
- package/theme/minimap.css +1 -1
- package/build/minimap.js.map +0 -1
package/src/minimapiframeview.js
CHANGED
|
@@ -1,115 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 minimap/minimapiframeview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { IframeView } from 'ckeditor5/src/ui';
|
|
11
9
|
import { toUnit } from 'ckeditor5/src/utils';
|
|
12
|
-
|
|
13
|
-
const toPx = toUnit( 'px' );
|
|
14
|
-
|
|
10
|
+
const toPx = toUnit('px');
|
|
15
11
|
/**
|
|
16
12
|
* The internal `<iframe>` view that hosts the minimap content.
|
|
17
13
|
*
|
|
18
|
-
* @
|
|
19
|
-
* @extends module:ui/iframe/iframeview~IframeView
|
|
14
|
+
* @internal
|
|
20
15
|
*/
|
|
21
16
|
export default class MinimapIframeView extends IframeView {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
* @inheritDoc
|
|
77
|
-
*/
|
|
78
|
-
render() {
|
|
79
|
-
return super.render().then( () => {
|
|
80
|
-
this._prepareDocument();
|
|
81
|
-
} );
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Sets the new height of the iframe.
|
|
86
|
-
*
|
|
87
|
-
* @param {Number} newHeight
|
|
88
|
-
*/
|
|
89
|
-
setHeight( newHeight ) {
|
|
90
|
-
this.height = newHeight;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Sets the top offset of the iframe to move it around vertically.
|
|
95
|
-
*
|
|
96
|
-
* @param {Number} newOffset
|
|
97
|
-
*/
|
|
98
|
-
setTopOffset( newOffset ) {
|
|
99
|
-
this.top = newOffset;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Sets the internal structure of the `<iframe>` readying it to display the
|
|
104
|
-
* minimap element.
|
|
105
|
-
*
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
_prepareDocument() {
|
|
109
|
-
const iframeDocument = this.element.contentWindow.document;
|
|
110
|
-
const domRootClone = iframeDocument.adoptNode( this._options.domRootClone );
|
|
111
|
-
|
|
112
|
-
const boxStyles = this._options.useSimplePreview ? `
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of the internal minimap iframe.
|
|
19
|
+
*/
|
|
20
|
+
constructor(locale, options) {
|
|
21
|
+
super(locale);
|
|
22
|
+
const bind = this.bindTemplate;
|
|
23
|
+
this.set('top', 0);
|
|
24
|
+
this.set('height', 0);
|
|
25
|
+
this._options = options;
|
|
26
|
+
this.extendTemplate({
|
|
27
|
+
attributes: {
|
|
28
|
+
class: [
|
|
29
|
+
'ck-minimap__iframe'
|
|
30
|
+
],
|
|
31
|
+
style: {
|
|
32
|
+
top: bind.to('top', top => toPx(top)),
|
|
33
|
+
height: bind.to('height', height => toPx(height))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
render() {
|
|
42
|
+
return super.render().then(() => {
|
|
43
|
+
this._prepareDocument();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sets the new height of the iframe.
|
|
48
|
+
*/
|
|
49
|
+
setHeight(newHeight) {
|
|
50
|
+
this.height = newHeight;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sets the top offset of the iframe to move it around vertically.
|
|
54
|
+
*/
|
|
55
|
+
setTopOffset(newOffset) {
|
|
56
|
+
this.top = newOffset;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets the internal structure of the `<iframe>` readying it to display the
|
|
60
|
+
* minimap element.
|
|
61
|
+
*/
|
|
62
|
+
_prepareDocument() {
|
|
63
|
+
const iframeDocument = this.element.contentWindow.document;
|
|
64
|
+
const domRootClone = iframeDocument.adoptNode(this._options.domRootClone);
|
|
65
|
+
const boxStyles = this._options.useSimplePreview ? `
|
|
113
66
|
.ck.ck-editor__editable_inline img {
|
|
114
67
|
filter: contrast( 0 );
|
|
115
68
|
}
|
|
@@ -124,20 +77,19 @@ export default class MinimapIframeView extends IframeView {
|
|
|
124
77
|
color: hsl(0, 0%, 60%) !important;
|
|
125
78
|
}
|
|
126
79
|
` : '';
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const html = `<!DOCTYPE html><html lang="en">
|
|
80
|
+
const pageStyles = this._options.pageStyles.map(definition => {
|
|
81
|
+
if (typeof definition === 'string') {
|
|
82
|
+
return `<style>${definition}</style>`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return `<link rel="stylesheet" type="text/css" href="${definition.href}">`;
|
|
86
|
+
}
|
|
87
|
+
}).join('\n');
|
|
88
|
+
const html = `<!DOCTYPE html><html lang="en">
|
|
137
89
|
<head>
|
|
138
90
|
<meta charset="utf-8">
|
|
139
91
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
140
|
-
${
|
|
92
|
+
${pageStyles}
|
|
141
93
|
<style>
|
|
142
94
|
html, body {
|
|
143
95
|
margin: 0 !important;
|
|
@@ -149,7 +101,7 @@ export default class MinimapIframeView extends IframeView {
|
|
|
149
101
|
}
|
|
150
102
|
|
|
151
103
|
body {
|
|
152
|
-
transform: scale( ${
|
|
104
|
+
transform: scale( ${this._options.scaleRatio} );
|
|
153
105
|
transform-origin: 0 0;
|
|
154
106
|
overflow: visible;
|
|
155
107
|
}
|
|
@@ -165,15 +117,14 @@ export default class MinimapIframeView extends IframeView {
|
|
|
165
117
|
background: white;
|
|
166
118
|
}
|
|
167
119
|
|
|
168
|
-
${
|
|
120
|
+
${boxStyles}
|
|
169
121
|
</style>
|
|
170
122
|
</head>
|
|
171
|
-
<body class="${
|
|
123
|
+
<body class="${this._options.extraClasses || ''}"></body>
|
|
172
124
|
</html>`;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
125
|
+
iframeDocument.open();
|
|
126
|
+
iframeDocument.write(html);
|
|
127
|
+
iframeDocument.close();
|
|
128
|
+
iframeDocument.body.appendChild(domRootClone);
|
|
129
|
+
}
|
|
179
130
|
}
|
|
@@ -1,134 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 minimap/minimappositiontrackerview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { View } from 'ckeditor5/src/ui';
|
|
11
9
|
import { toUnit, global } from 'ckeditor5/src/utils';
|
|
12
|
-
|
|
13
|
-
const toPx = toUnit( 'px' );
|
|
14
|
-
|
|
10
|
+
const toPx = toUnit('px');
|
|
15
11
|
/**
|
|
16
12
|
* The position tracker visualizing the visible subset of the content. Displayed over the minimap.
|
|
17
13
|
*
|
|
18
|
-
* @
|
|
19
|
-
* @extends module:ui/view~View
|
|
14
|
+
* @internal
|
|
20
15
|
*/
|
|
21
16
|
export default class MinimapPositionTrackerView extends View {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
* @event drag
|
|
85
|
-
* @param {Number} movementY The vertical movement of the tracker as a result of dragging.
|
|
86
|
-
*/
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @inheritDoc
|
|
91
|
-
*/
|
|
92
|
-
render() {
|
|
93
|
-
super.render();
|
|
94
|
-
|
|
95
|
-
this.listenTo( global.document, 'mousemove', ( evt, data ) => {
|
|
96
|
-
if ( !this._isDragging ) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.fire( 'drag', data.movementY );
|
|
101
|
-
}, { useCapture: true } );
|
|
102
|
-
|
|
103
|
-
this.listenTo( global.document, 'mouseup', () => {
|
|
104
|
-
this._isDragging = false;
|
|
105
|
-
}, { useCapture: true } );
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Sets the new height of the tracker to visualize the subset of the content visible to the user.
|
|
110
|
-
*
|
|
111
|
-
* @param {Number} newHeight
|
|
112
|
-
*/
|
|
113
|
-
setHeight( newHeight ) {
|
|
114
|
-
this.height = newHeight;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Sets the top offset of the tracker to move it around vertically.
|
|
119
|
-
*
|
|
120
|
-
* @param {Number} newOffset
|
|
121
|
-
*/
|
|
122
|
-
setTopOffset( newOffset ) {
|
|
123
|
-
this.top = newOffset;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Sets the scroll progress (in %) to inform the user using a label when the tracker is being dragged.
|
|
128
|
-
*
|
|
129
|
-
* @param {Number} newProgress
|
|
130
|
-
*/
|
|
131
|
-
setScrollProgress( newProgress ) {
|
|
132
|
-
this.scrollProgress = newProgress;
|
|
133
|
-
}
|
|
17
|
+
constructor(locale) {
|
|
18
|
+
super(locale);
|
|
19
|
+
const bind = this.bindTemplate;
|
|
20
|
+
this.set('height', 0);
|
|
21
|
+
this.set('top', 0);
|
|
22
|
+
this.set('scrollProgress', 0);
|
|
23
|
+
this.set('_isDragging', false);
|
|
24
|
+
this.setTemplate({
|
|
25
|
+
tag: 'div',
|
|
26
|
+
attributes: {
|
|
27
|
+
class: [
|
|
28
|
+
'ck',
|
|
29
|
+
'ck-minimap__position-tracker',
|
|
30
|
+
bind.if('_isDragging', 'ck-minimap__position-tracker_dragging')
|
|
31
|
+
],
|
|
32
|
+
style: {
|
|
33
|
+
top: bind.to('top', top => toPx(top)),
|
|
34
|
+
height: bind.to('height', height => toPx(height))
|
|
35
|
+
},
|
|
36
|
+
'data-progress': bind.to('scrollProgress')
|
|
37
|
+
},
|
|
38
|
+
on: {
|
|
39
|
+
mousedown: bind.to(() => {
|
|
40
|
+
this._isDragging = true;
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
render() {
|
|
49
|
+
super.render();
|
|
50
|
+
this.listenTo(global.document, 'mousemove', (evt, data) => {
|
|
51
|
+
if (!this._isDragging) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.fire('drag', data.movementY);
|
|
55
|
+
}, { useCapture: true });
|
|
56
|
+
this.listenTo(global.document, 'mouseup', () => {
|
|
57
|
+
this._isDragging = false;
|
|
58
|
+
}, { useCapture: true });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sets the new height of the tracker to visualize the subset of the content visible to the user.
|
|
62
|
+
*/
|
|
63
|
+
setHeight(newHeight) {
|
|
64
|
+
this.height = newHeight;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sets the top offset of the tracker to move it around vertically.
|
|
68
|
+
*/
|
|
69
|
+
setTopOffset(newOffset) {
|
|
70
|
+
this.top = newOffset;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sets the scroll progress (in %) to inform the user using a label when the tracker is being dragged.
|
|
74
|
+
*/
|
|
75
|
+
setScrollProgress(newProgress) {
|
|
76
|
+
this.scrollProgress = newProgress;
|
|
77
|
+
}
|
|
134
78
|
}
|