@ckeditor/ckeditor5-minimap 39.0.2 → 40.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.
@@ -1,67 +1,67 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module minimap/minimapiframeview
7
- */
8
- import { IframeView } from 'ckeditor5/src/ui';
9
- import { toUnit } from 'ckeditor5/src/utils';
10
- const toPx = toUnit('px');
11
- /**
12
- * The internal `<iframe>` view that hosts the minimap content.
13
- *
14
- * @internal
15
- */
16
- export default class MinimapIframeView extends IframeView {
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);
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module minimap/minimapiframeview
7
+ */
8
+ import { IframeView } from 'ckeditor5/src/ui';
9
+ import { toUnit } from 'ckeditor5/src/utils';
10
+ const toPx = toUnit('px');
11
+ /**
12
+ * The internal `<iframe>` view that hosts the minimap content.
13
+ *
14
+ * @internal
15
+ */
16
+ export default class MinimapIframeView extends IframeView {
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
65
  const boxStyles = this._options.useSimplePreview ? `
66
66
  .ck.ck-editor__editable_inline img {
67
67
  filter: contrast( 0 );
@@ -76,15 +76,15 @@ export default class MinimapIframeView extends IframeView {
76
76
  background: hsl(0, 0%, 60%) !important;
77
77
  color: hsl(0, 0%, 60%) !important;
78
78
  }
79
- ` : '';
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');
79
+ ` : '';
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
88
  const html = `<!DOCTYPE html><html lang="en">
89
89
  <head>
90
90
  <meta charset="utf-8">
@@ -121,10 +121,10 @@ export default class MinimapIframeView extends IframeView {
121
121
  </style>
122
122
  </head>
123
123
  <body class="${this._options.extraClasses || ''}"></body>
124
- </html>`;
125
- iframeDocument.open();
126
- iframeDocument.write(html);
127
- iframeDocument.close();
128
- iframeDocument.body.appendChild(domRootClone);
129
- }
130
- }
124
+ </html>`;
125
+ iframeDocument.open();
126
+ iframeDocument.write(html);
127
+ iframeDocument.close();
128
+ iframeDocument.body.appendChild(domRootClone);
129
+ }
130
+ }
@@ -1,58 +1,58 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module minimap/minimappositiontrackerview
7
- */
8
- import { View } from 'ckeditor5/src/ui';
9
- import { type Locale } from 'ckeditor5/src/utils';
10
- /**
11
- * The position tracker visualizing the visible subset of the content. Displayed over the minimap.
12
- *
13
- * @internal
14
- */
15
- export default class MinimapPositionTrackerView extends View {
16
- /**
17
- * The CSS `height` of the tracker visualizing the subset of the content visible to the user.
18
- *
19
- * @readonly
20
- */
21
- height: number;
22
- /**
23
- * The CSS `top` of the tracker, used to move it vertically over the minimap.
24
- *
25
- * @readonly
26
- */
27
- top: number;
28
- /**
29
- * The scroll progress (in %) displayed over the tracker when being dragged by the user.
30
- *
31
- * @readonly
32
- */
33
- scrollProgress: number;
34
- /**
35
- * Indicates whether the tracker is being dragged by the user (e.g. using the mouse).
36
- *
37
- * @internal
38
- * @readonly
39
- */
40
- _isDragging: boolean;
41
- constructor(locale: Locale);
42
- /**
43
- * @inheritDoc
44
- */
45
- render(): void;
46
- /**
47
- * Sets the new height of the tracker to visualize the subset of the content visible to the user.
48
- */
49
- setHeight(newHeight: number): void;
50
- /**
51
- * Sets the top offset of the tracker to move it around vertically.
52
- */
53
- setTopOffset(newOffset: number): void;
54
- /**
55
- * Sets the scroll progress (in %) to inform the user using a label when the tracker is being dragged.
56
- */
57
- setScrollProgress(newProgress: number): void;
58
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module minimap/minimappositiontrackerview
7
+ */
8
+ import { View } from 'ckeditor5/src/ui';
9
+ import { type Locale } from 'ckeditor5/src/utils';
10
+ /**
11
+ * The position tracker visualizing the visible subset of the content. Displayed over the minimap.
12
+ *
13
+ * @internal
14
+ */
15
+ export default class MinimapPositionTrackerView extends View {
16
+ /**
17
+ * The CSS `height` of the tracker visualizing the subset of the content visible to the user.
18
+ *
19
+ * @readonly
20
+ */
21
+ height: number;
22
+ /**
23
+ * The CSS `top` of the tracker, used to move it vertically over the minimap.
24
+ *
25
+ * @readonly
26
+ */
27
+ top: number;
28
+ /**
29
+ * The scroll progress (in %) displayed over the tracker when being dragged by the user.
30
+ *
31
+ * @readonly
32
+ */
33
+ scrollProgress: number;
34
+ /**
35
+ * Indicates whether the tracker is being dragged by the user (e.g. using the mouse).
36
+ *
37
+ * @internal
38
+ * @readonly
39
+ */
40
+ _isDragging: boolean;
41
+ constructor(locale: Locale);
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ render(): void;
46
+ /**
47
+ * Sets the new height of the tracker to visualize the subset of the content visible to the user.
48
+ */
49
+ setHeight(newHeight: number): void;
50
+ /**
51
+ * Sets the top offset of the tracker to move it around vertically.
52
+ */
53
+ setTopOffset(newOffset: number): void;
54
+ /**
55
+ * Sets the scroll progress (in %) to inform the user using a label when the tracker is being dragged.
56
+ */
57
+ setScrollProgress(newProgress: number): void;
58
+ }
@@ -1,78 +1,78 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module minimap/minimappositiontrackerview
7
- */
8
- import { View } from 'ckeditor5/src/ui';
9
- import { toUnit, global } from 'ckeditor5/src/utils';
10
- const toPx = toUnit('px');
11
- /**
12
- * The position tracker visualizing the visible subset of the content. Displayed over the minimap.
13
- *
14
- * @internal
15
- */
16
- export default class MinimapPositionTrackerView extends View {
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
- }
78
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module minimap/minimappositiontrackerview
7
+ */
8
+ import { View } from 'ckeditor5/src/ui';
9
+ import { toUnit, global } from 'ckeditor5/src/utils';
10
+ const toPx = toUnit('px');
11
+ /**
12
+ * The position tracker visualizing the visible subset of the content. Displayed over the minimap.
13
+ *
14
+ * @internal
15
+ */
16
+ export default class MinimapPositionTrackerView extends View {
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
+ }
78
+ }
@@ -1,109 +1,109 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module minimap/minimapview
7
- */
8
- import { View } from 'ckeditor5/src/ui';
9
- import { type Locale } from 'ckeditor5/src/utils';
10
- export type MinimapViewOptions = {
11
- domRootClone: HTMLElement;
12
- pageStyles: Array<string | {
13
- href: string;
14
- }>;
15
- scaleRatio: number;
16
- useSimplePreview?: boolean;
17
- extraClasses?: string;
18
- };
19
- /**
20
- * The main view of the minimap. It renders the original content but scaled down with a tracker element
21
- * visualizing the subset of the content visible to the user and allowing interactions (scrolling, dragging).
22
- *
23
- * @internal
24
- */
25
- export default class MinimapView extends View {
26
- /**
27
- * An instance of the tracker view displayed over the minimap.
28
- */
29
- private readonly _positionTrackerView;
30
- /**
31
- * The scale ratio of the minimap relative to the original editing DOM root with the content.
32
- */
33
- private readonly _scaleRatio;
34
- /**
35
- * An instance of the iframe view that hosts the minimap.
36
- */
37
- private readonly _minimapIframeView;
38
- /**
39
- * Creates an instance of the minimap view.
40
- */
41
- constructor({ locale, scaleRatio, pageStyles, extraClasses, useSimplePreview, domRootClone }: {
42
- locale: Locale;
43
- } & MinimapViewOptions);
44
- /**
45
- * @inheritDoc
46
- */
47
- destroy(): void;
48
- /**
49
- * Returns the DOM {@link module:utils/dom/rect~Rect} height of the minimap.
50
- */
51
- get height(): number;
52
- /**
53
- * Returns the number of available space (pixels) the position tracker (visible subset of the content) can use to scroll vertically.
54
- */
55
- get scrollHeight(): number;
56
- /**
57
- * @inheritDoc
58
- */
59
- render(): void;
60
- /**
61
- * Sets the new height of the minimap (in px) to respond to the changes in the original editing DOM root.
62
- *
63
- * **Note**:The provided value should be the `offsetHeight` of the original editing DOM root.
64
- */
65
- setContentHeight(newHeight: number): void;
66
- /**
67
- * Sets the minimap scroll progress.
68
- *
69
- * The minimap scroll progress is linked to the original editing DOM root and its scrollable container (ancestor).
70
- * Changing the progress will alter the vertical position of the minimap (and its position tracker) and give the user an accurate
71
- * overview of the visible document.
72
- *
73
- * **Note**: The value should be between 0 and 1. 0 when the DOM root has not been scrolled, 1 when the
74
- * scrolling has reached the end.
75
- */
76
- setScrollProgress(newScrollProgress: number): void;
77
- /**
78
- * Sets the new height of the tracker (in px) to visualize the subset of the content visible to the user.
79
- */
80
- setPositionTrackerHeight(trackerHeight: number): void;
81
- /**
82
- * @param data DOM event data
83
- */
84
- private _handleMinimapClick;
85
- /**
86
- * @param data DOM event data
87
- */
88
- private _handleMinimapMouseWheel;
89
- }
90
- /**
91
- * Fired when the minimap view is clicked.
92
- *
93
- * @eventName ~MinimapView#click
94
- * @param percentage The number between 0 and 1 representing a place in the minimap (its height) that was clicked.
95
- */
96
- export type MinimapClickEvent = {
97
- name: 'click';
98
- args: [percentage: number];
99
- };
100
- /**
101
- * Fired when the position tracker is dragged or the minimap is scrolled via mouse wheel.
102
- *
103
- * @eventName ~MinimapView#drag
104
- * @param movementY The vertical movement of the minimap as a result of dragging or scrolling.
105
- */
106
- export type MinimapDragEvent = {
107
- name: 'drag';
108
- args: [movementY: number];
109
- };
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module minimap/minimapview
7
+ */
8
+ import { View } from 'ckeditor5/src/ui';
9
+ import { type Locale } from 'ckeditor5/src/utils';
10
+ export type MinimapViewOptions = {
11
+ domRootClone: HTMLElement;
12
+ pageStyles: Array<string | {
13
+ href: string;
14
+ }>;
15
+ scaleRatio: number;
16
+ useSimplePreview?: boolean;
17
+ extraClasses?: string;
18
+ };
19
+ /**
20
+ * The main view of the minimap. It renders the original content but scaled down with a tracker element
21
+ * visualizing the subset of the content visible to the user and allowing interactions (scrolling, dragging).
22
+ *
23
+ * @internal
24
+ */
25
+ export default class MinimapView extends View {
26
+ /**
27
+ * An instance of the tracker view displayed over the minimap.
28
+ */
29
+ private readonly _positionTrackerView;
30
+ /**
31
+ * The scale ratio of the minimap relative to the original editing DOM root with the content.
32
+ */
33
+ private readonly _scaleRatio;
34
+ /**
35
+ * An instance of the iframe view that hosts the minimap.
36
+ */
37
+ private readonly _minimapIframeView;
38
+ /**
39
+ * Creates an instance of the minimap view.
40
+ */
41
+ constructor({ locale, scaleRatio, pageStyles, extraClasses, useSimplePreview, domRootClone }: {
42
+ locale: Locale;
43
+ } & MinimapViewOptions);
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ destroy(): void;
48
+ /**
49
+ * Returns the DOM {@link module:utils/dom/rect~Rect} height of the minimap.
50
+ */
51
+ get height(): number;
52
+ /**
53
+ * Returns the number of available space (pixels) the position tracker (visible subset of the content) can use to scroll vertically.
54
+ */
55
+ get scrollHeight(): number;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ render(): void;
60
+ /**
61
+ * Sets the new height of the minimap (in px) to respond to the changes in the original editing DOM root.
62
+ *
63
+ * **Note**:The provided value should be the `offsetHeight` of the original editing DOM root.
64
+ */
65
+ setContentHeight(newHeight: number): void;
66
+ /**
67
+ * Sets the minimap scroll progress.
68
+ *
69
+ * The minimap scroll progress is linked to the original editing DOM root and its scrollable container (ancestor).
70
+ * Changing the progress will alter the vertical position of the minimap (and its position tracker) and give the user an accurate
71
+ * overview of the visible document.
72
+ *
73
+ * **Note**: The value should be between 0 and 1. 0 when the DOM root has not been scrolled, 1 when the
74
+ * scrolling has reached the end.
75
+ */
76
+ setScrollProgress(newScrollProgress: number): void;
77
+ /**
78
+ * Sets the new height of the tracker (in px) to visualize the subset of the content visible to the user.
79
+ */
80
+ setPositionTrackerHeight(trackerHeight: number): void;
81
+ /**
82
+ * @param data DOM event data
83
+ */
84
+ private _handleMinimapClick;
85
+ /**
86
+ * @param data DOM event data
87
+ */
88
+ private _handleMinimapMouseWheel;
89
+ }
90
+ /**
91
+ * Fired when the minimap view is clicked.
92
+ *
93
+ * @eventName ~MinimapView#click
94
+ * @param percentage The number between 0 and 1 representing a place in the minimap (its height) that was clicked.
95
+ */
96
+ export type MinimapClickEvent = {
97
+ name: 'click';
98
+ args: [percentage: number];
99
+ };
100
+ /**
101
+ * Fired when the position tracker is dragged or the minimap is scrolled via mouse wheel.
102
+ *
103
+ * @eventName ~MinimapView#drag
104
+ * @param movementY The vertical movement of the minimap as a result of dragging or scrolling.
105
+ */
106
+ export type MinimapDragEvent = {
107
+ name: 'drag';
108
+ args: [movementY: number];
109
+ };